各位大侠,小弟想查询从1行到999行的数据,用了rownum ,sql语句如下    select distinct(phone_no),count(*) as num from KFWEB_OPERATELOG 
    where rownum < 1000 group by phone_no order by num;为什么查询出来的结果只有700多行,去掉rownum < 1000 ,查询出来的数据有10000多行啊,这个该怎么办呢,谢谢大家了!!!

解决方案 »

  1.   

    rownum   <   1000  先于group by 执行
      

  2.   

    select * from 
    (select distinct(phone_no),count(*) as num from KFWEB_OPERATELOG   
            group by phone_no order by num)
    where   rownum < 1000; 
      

  3.   

    oracle里要这么写
    select * from 
    ( select   distinct(phone_no),count(*)   as   num   from   KFWEB_OPERATELOG   
            where    group   by   phone_no   order   by   num ) 
    where rownum   <   1000  
      

  4.   

    select * from 
    (select distinct(phone_no),count(*) as num from KFWEB_OPERATELOG   
            group by phone_no order by num)
    where   rownum < 1000; 
      

  5.   

    我觉得rownum好像不一定是连续的吧,猜测。
      

  6.   

    select * from 
    (select distinct(phone_no),count(*) as num from KFWEB_OPERATELOG   
            group by phone_no order by num)
    where   rownum < 1000
    minus
    select * from 
    (select distinct(phone_no),count(*) as num from KFWEB_OPERATELOG   
            group by phone_no order by num)
    where   rownum < 50