如何将此转换为触发器(学生排名)
SET @prev_value = NULL;
SET @rank_count = 0;
SET @rank_increasing = 0;
SELECT @rank_increasing := @rank_increasing + 1 AS NO
, CASE
WHEN @prev_value = a.total_score
THEN @rank_count
WHEN @prev_value := a.total_score
THEN @rank_count := @rank_increasing
END AS RANK
, a.*
FROM ( SELECT STUDENT_ID,TERM,YEAR,
SUM(TEST) AS total_score
FROM studentmark
GROUP BY STUDENT_ID
ORDER BY total_score DESC
) a
任何人都可以帮我做这个