sql練習-檢索"01"課程分數小於60,按分數降序排列的學生信息

 

有四張表:Course(課程)、SC(成績)、Student(學生)、Teacher(老師)spa


 

想法:這裏用到SC和Student兩個表,首先得先肯定篩選條件,01課程成績小於60。而後,LEFT JOIN鏈接Student,再用到了ORDER BY ...  DESCcode

 

注意:降序(從高到低或從大到小)爲DESC,升序(從低到高從小到大)爲ASC,若是省略ASC或DESC系統則默認爲升序
blog

 

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

結果以下:ci

 

 

 


 

  各位如有建議與疑問,歡迎提出討論;如有什麼不對之處,歡迎批評指正。class

相關文章
相關標籤/搜索