SELECT B.*, C.matchAddress, C.matchContent, C.matchTime, D.XM, @curRank := IF(@prevRank = B.avgScore, @curRank, @incRank) AS rank, @incRank := @incRank + 1,
@prevRank := B.avgScore
FROM (
SELECT avg(score) as avgScore, matchClassId, teacherId
from Tea_MatchTeacherScore A, (
SELECT @curRank :=0, @prevRank := NULL, @incRank := 1
) r
GROUP BY matchClassId, teacherId) B
LEFT JOIN Tea_MatchClass C ON B.matchClassId = C.id
LEFT JOIN Tea_Teacher D ON B.teacherId = D.id
ORDER BY avgScore desc
版权声明:本文为zy_1558538904原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。