50道SQL练习题

1

select a.*,b.score as 01_score,c.score as 02_score from student           a,sc b,sc c 
            where a.SId=b.SId 
            and b.SId=c.SId 
            and b.CId='01' 
            and c.CId='02' 
            and b.score>c.score
image.png
SELECT t.*,student.Sage,student.Sname,student.Ssex
FROM
(
  SELECT sc1.SId,sc1.score 01score,sc2.score 02score
  FROM sc sc1,sc sc2
  WHERE sc1.SId=sc2.SId AND sc1.score>sc2.score AND sc1.CId='01'AND sc2.CId='02'
) AS t
LEFT JOIN student 
ON t.SId=student.SId
image.png

2
未完待续。。。

你可能感兴趣的:(50道SQL练习题)