【发布时间】:2019-04-17 15:15:49
【问题描述】:
有一个表有 4 列:id、student_name、phone_num、score。 我想根据分数选择前3名的学生。
表:
id|student_name |phone_num|score
1 | James | 001350 | 89
2 | Roomi | 123012 | 78
3 | Sibay | 123012 | 65
4 | Ellae | 123012 | 78
5 | Katee | 123012 | 33
如表所示,有两个学生的分数相同。 所以他们的排名是一样的。
我尝试使用“LIMIT”,但它只能选择 3 行。
SELECT id,student_name,score
FROM table
GROUP BY id,student_name,score
ORDER BY score
LIMIT 3
预期结果:
id|student_name |score
1 | James | 89
2 | Roomi | 78
4 | Ellae | 78
3 | Sibay | 65
谢谢!
【问题讨论】:
-
AFAIK SQL Server 中没有 LIMIT 关键字。你确定你正确地标记了这个问题吗?
标签: sql sql-server