Distinct
Group By
より遅い 。 Group By
を使用せずにこのようにすることができます およびDistinct
一緒に、これはあなたが達成したいことかもしれません。
SELECT regd, Roll_no, Name_of_Student, Name_of_exam,
TOTALSCORE, Rank
FROM
(
SELECT t.*, IF(@p = TOTALSCORE, @n, @n := @n + 1) AS Rank, @p := TOTALSCORE
FROM
(
SELECT regd, Roll_no, Name_of_Student, Name_of_exam,
SUM(Mark_score) TOTALSCORE
FROM cixexam, (SELECT @n := 0, @p := 0) n
WHERE (Name_of_exam='First Terminal Exam' OR Name_of_exam='First Term Test')
GROUP BY regd
ORDER BY TOTALSCORE DESC
) t
) r