从zyz2表中随机取出两条纪录: SQL> select * from zyz2; ID P1 P2 ---------- ---------- ---------- 1 211 212 2 12 14 4 241 242 2 145 1 11 3 17 26 rows selected.Elapsed: 00:00:00.50 SQL> select id,p1,p2 from (select zyz2.*,dbms_random.random num from zyz2 order by num) where rownum<3; ID P1 P2 ---------- ---------- ---------- 2 12 14 1 211 212Elapsed: 00:00:00.30 SQL> select id,p1,p2 from (select zyz2.*,dbms_random.random num from zyz2 order by num) where rownum<3; ID P1 P2 ---------- ---------- ---------- 3 17 2 2 12 14 8i以上 select * from (select * from ur_table order by sys_guid()) where rownum<n; select * from (select * from ur_table order by dbms_random.value) where rownum<n;
我试了试以下语句 select dsistinct phone from ( select phone , dbms_random.random phone from phonemast where ( date between '01/11/03'and '31/12/03' and salagent>='01' and salagent<='99' order by phone ) where rownum<11;它老是说我在order前少了一个右括号。请问各位我这语句问题在哪里啊?谢谢
select dsistinct phone from ( select phone , dbms_random.random phone from phonemast where ( date between '01/11/03'and '31/12/03' and salagent>='01' and salagent<='99' order by phone )) where rownum<11;
sorry,应该是这样的,上面我写错了。 select dsistinct phone from ( select phone , dbms_random.random phone from phonemast where date between '01/11/03'and '31/12/03' and salagent>='01' and salagent<='99' order by phone ) where rownum<11;并且它是说我在order前少了一个括号!!真是不好意思!
SQL> select * from zyz2;
ID P1 P2
---------- ---------- ----------
1 211 212
2 12 14
4 241 242
2 145
1 11
3 17 26 rows selected.Elapsed: 00:00:00.50
SQL> select id,p1,p2 from (select zyz2.*,dbms_random.random num from zyz2 order
by num) where rownum<3; ID P1 P2
---------- ---------- ----------
2 12 14
1 211 212Elapsed: 00:00:00.30
SQL> select id,p1,p2 from (select zyz2.*,dbms_random.random num from zyz2 order
by num) where rownum<3; ID P1 P2
---------- ---------- ----------
3 17 2
2 12 14
8i以上
select * from (select * from ur_table order by sys_guid()) where rownum<n;
select * from (select * from ur_table order by dbms_random.value) where rownum<n;
select dsistinct phone from ( select phone , dbms_random.random phone from
phonemast where ( date between '01/11/03'and '31/12/03'
and salagent>='01' and salagent<='99' order by phone ) where rownum<11;它老是说我在order前少了一个右括号。请问各位我这语句问题在哪里啊?谢谢
phonemast where ( date between '01/11/03'and '31/12/03'
and salagent>='01' and salagent<='99' order by phone )) where rownum<11;
select dsistinct phone from ( select phone , dbms_random.random phone from
phonemast where date between '01/11/03'and '31/12/03'
and salagent>='01' and salagent<='99' order by phone ) where rownum<11;并且它是说我在order前少了一个括号!!真是不好意思!