我现在要实现这样一个功能
在一个表中查询数据,然后按时间排序比如说查到了1000个数据
那么我现在要每隔10个数据选择一个数据
那就是在这1000个数据中取出其中的100个该怎么来写这段sql语句呢

解决方案 »

  1.   

    select * from (select t.*,rownum num from 表 t) where num||'' like '%0'红色的数字表示你要去的尾数,如果是0,则取10、20、30、40.....
    如果是1,则取1、11、21、31......
    .......
    如果是9,则取9、19、29.....
      

  2.   

    不好意思,没有rownum这么明显的表示的
    排序是以日期来拍的
      

  3.   

    把你要的排序加到1楼sql的from后面那个查询里就可以了
      

  4.   

    排完序后oracle数据库自动给那些记录序号的
      

  5.   


    rownum是oracle自带的编号字段呀select * from 
    (select t.*,rownum num from (select * from 表 order by 时间) t) 
    where num||'' like '%0'
    这样应该可以了
      

  6.   

    select * from 
    (select id,datetime,name,rownum rn
    from test_03 order by datetime) 
    where rn like '%0';
      

  7.   


    Where 条件中加上Mod函数就可以了
      

  8.   

    不好意思,引用错了Where 条件中加上Mod函数就可以了
      

  9.   

    select * from 
    (select t.*,rownum num from (select * from 表 order by 时间) t) 
    where mod(num,6)=ii取值0-5