多字段分组查询

WITH tmp AS (
select max(autoScore) score,z.courseID
from QZ_MEMBER_PAPER_SCORE as z where z.userID=1 and z.isExam != 0
group by z.courseID
)
SELECT b.*
FROM tmp a JOIN QZ_MEMBER_PAPER_SCORE b ON a.score=b.autoScore AND a.courseID=b.courseID

你可能感兴趣的:(查询)