现在的位置: 首页 > 综合 > 正文

随机抽取表中数据

2012年11月24日 ⁄ 综合 ⁄ 共 355字 ⁄ 字号 评论关闭

方法1:

select gmsfhm, xm

 from ( select gmsfhm, xm from czrk where gmsfhm like '%%' order by dbms_random.value )

 where rownum <= 100

方法2:

select gmsfhm, xm
  from ( select gmsfhm, xm from czrk where gmsfhm like '%%' order by dbms_random.random )

  where rownum <= 100;

方法3:(速度会快点)

select gmsfhm,xm

  from ( select gmsfhm, xm from czrk sample(1) where gmsfhm like '%%' order by dbms_random.random )

  where rownum <= 100;

抱歉!评论已关闭.