select name,score from (
select name,score,dense_rank() over(order by score) "row" from t )
where "row"=10
先用group by以成绩分组,再用top取前十个。
select top 10 姓名,分数 from 成绩表
group by 成绩
sql
数据库怎样检索出每个班级里总分数top10的学生姓名,并按班级和总分排名:
select
class,grade
from
student
group
by
class
having top10(grade)
这里用一下top方法就可以定位到你想要的那一行啦
希望我的回答对你会有帮助
取到排名的前十位:
with RK as(
select Stu_score,Stu_name,
DENSE_RANK()over(order by stu_score desc)as rank
from StudentScore) select top 10
RK.* from RK
取到排名的前十名:
with RK as(
select Stu_score,Stu_name,
DENSE_RANK()over(order by stu_score desc)as rank
from StudentScore) select
* from RK where RK.rank <='10'