SELECTstudent.*,sc.CId,sc.scoreFROMstudent,(SELECTt1.SIdFROM( SELECT * FROM sc WHERE CId = 01 ) t1,(SELECT*FROMscWHERECId = 02) t2WHEREt1.SId = t2.SIdAND t1.score > t2.score) t3,scWHEREstudent.SId = t3.SIdAND sc.SId = t3.SId
SELECT
t2.SId,
t2.Sname,
t1.Avg
FROM
( SELECT SId, CAST( AVG( score ) AS DECIMAL ( 10, 2 )) Avg FROM sc GROUP BY SId ) t1,
student t2
WHERE
t1.SId = t2.SId
AND t1.Avg >= 60
