select score from userTb order by score DESC(按倒序排序)
用sql%rowno获取返回的行数

解决方案 »

  1.   

    ****用sql%rowno获取返回的行数这一句我不是很明白?我是用存储过程写的
    我就是想知道如何得到用户的名次呢?
      

  2.   

    假设用户成绩表为t_score,其中c_userid为用户ID,c_score为该用户得分
    t_score
    --------------------
    c_userid c_score
    --------------------
    131    85
    126    79
    147    90
    113    85则
    select to_char(a.c_userid) || ',恭喜你是第' || to_char(a.c_rank) || '名!'
    from ( select c_userid, rank() over (order by c_score) c_rank from t_score ) a
    where a.c_userid = (用户ID)
      

  3.   

    select name,decode(rk,1,'恭喜你是第1名',2,'恭喜你是第2名',3,'恭喜你是第3名') 名次
    from 
    (select name,rank() over(order by score DESC) rk from talbe_name)
    order by score DESC
      

  4.   

    select c_userid,decode(rownum,ROWNUM,'共恭喜你得了'||rownum||'名') from talbe_nameorder by c_score desc;