mysql 查询每个班的前十名的成绩
发布网友
发布时间:2022-05-16 12:47
我来回答
共1个回答
热心网友
时间:2023-10-22 22:01
答:
试运行段:
select *
from(
SELECT
obj.id,
obj.score,
CASE
WHEN @rowtotal = obj.score THEN
@rownum
WHEN @rowtotal := obj.score THEN
@rownum :=@rownum + 1
WHEN @rowtotal = 0 THEN
@rownum :=@rownum + 1
END AS rownum
FROM
(
SELECT id,name,score
from test -- 表名字
ORDER BY score DESC
)) AS obj,
(SELECT @rownum := 0 ,@rowtotal := NULL) r
) as no2
where rownum < 4追问你好,有没有相关系统点的资料,比如储存过程和这方面的