有四张表:Course(课程)、SC(成绩)、Student(学生)、Teacher(老师)
想法:这里用到SC和Student两个表,首先得先确定筛选条件,01课程成绩小于60。然后,LEFT JOIN连接Student,再用到了ORDER BY ... DESC
注意:降序(从高到低或从大到小)为DESC,升序(从低到高或从小到大)为ASC,如果省略ASC或DESC系统则默认为升序
1 use LoginDB 2 go 3 select t1.sid as 学号,sname as 姓名,score as 成绩 --,sage as 出生年月,ssex as 性别 4 from 5 ( 6 select * from SC where cid = 01 and score < 60 7 )t1 8 left join Student 9 on t1.sid = Student.sid order by score desc
结果如下:
各位若有建议与疑问,欢迎提出讨论;若有什么不对之处,欢迎批评指正。