老调重弹的SQL写法,最近很少写代码,一时间忘记了。求助
------解决思路----------------------
++
楼主,排名用rank,dese_rank吧
with table_name(id,sc)as(
select 1,90 from dual
union all
select 2,90 from dual
union all
select 3,90 from dual
union all
select 4,77 from dual
)
SELECT id, sc, rank() over(ORDER BY sc DESC) rk, dense_rank() over(ORDER BY sc DESC) drk
FROM table_name;
--结果
ID SC RK DRK
---------- ---------- ---------- ----------
1 90 1 1
2 90 1 1
3 90 1 1
4 77 4 2
--通过这组数据可以看出相同排名后是否跳名次区别而已。