那位高手帮我写一条查询的sql语句可以吗?表结构是:
Name        Type          Nullable Default Comments 
----------- ------------- -------- ------- -------- 
MOBILE_NO   VARCHAR2(32)  Y                 手机号码        
ACCOUNT_NUM NUMBER        Y                 猜到的数据        
ACCOUNT     NUMBER        Y                 猜测次数        
SEND_TIME   VARCHAR2(100) Y                 猜数时间        要求查出最近五条记录,而且account_num必须是唯一且最小的! 很急,几分很少,望大侠帮忙,谢谢了!                  

解决方案 »

  1.   

    select * from 
    (select MOBILE_NO,ACCOUNT_NUM,ACCOUNT,SEND_TIME,row_number() over(partition by 
    send_time order by send_time desc,ACCOUNT_NUM desc) rn from 表)
    where rn<6 
      

  2.   

    --上面搞错了,
    select * from 
    (select MOBILE_NO,ACCOUNT_NUM,ACCOUNT,SEND_TIME,row_number() over(partition by 
    send_time order by send_time desc,ACCOUNT_NUM asc) rn from 表)
    where rn<6 
      

  3.   

    select *
      from your_table
     where account_num in (select account_num
                             from (select account_num
                                     from your_table
                                    where account_num is not null --这个根据你需要看是否要加
                                    group by account_num
                                   having count(*) <= 1
                                    order by account_num)
                            where rownum <= 5)这么来吧,根据account_num除重了
    不知道ACCOUNT是干嘛的
      

  4.   

    你的ACCOUNT是干嘛的?有用么?
    对于account_num一样的数据,你的account是不一样的么?
      

  5.   

    给你个求最小不重复的5个数字的算法
    -- 算出所有ACCOUNT_NUM无重复的记录
    SELECT ACCOUNT_NUM 
    FROM (SELECT ACCOUNT_NUM,ROWNUM RN 
        FROM TABLE1 
        GROUP BY ACCOUNT_NUM 
        HAVING COUNT(1) = 1 
        ORDER BY ACCOUNT_NUM) 
    WHERE RN <= 5