怎么用sql查询班级前十名成绩的同学的姓名和分数(成绩相同的学生算同一个名次)

2025-01-08 18:08:45
推荐回答(4个)
回答1:

select name,score from (

select name,score,dense_rank() over(order by score) "row" from t )
where "row"=10

回答2:

先用group by以成绩分组,再用top取前十个。
select top 10 姓名,分数 from 成绩表
group by 成绩

回答3:

sql
数据库怎样检索出每个班级里总分数top10的学生姓名,并按班级和总分排名:
select
class,grade
from
student
group
by
class
having top10(grade)
这里用一下top方法就可以定位到你想要的那一行啦
希望我的回答对你会有帮助

回答4:

取到排名的前十位:
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'