日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle:sql查询

發布時間:2024/4/14 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle:sql查询 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最近遇到一些查詢,自己還不是能保證一口氣就寫對,經過和好友一起研究,有一兩個比較好的思路,尤其是最后兩個查詢,值得深思。為紀念這一丁丁進步和思維的一小步跨越,現記錄如下:

--1.查詢所有同學的學號、姓名、選課數、總成績 select sc.sno,sname,count(sc.cno),sum(sc.grade) from student,sc where student.sno=sc.sno group by sc.sno,sname order by sc.sno; --2.查詢姓“趙”的老師的個數 select count(sno) from student where sname like '趙%'; --3.查詢選課門數大于2的學生的學號和姓名 select sc.sno,sname,count(sc.sno) from student,sc where student.sno = sc.sno group by sc.sno,sname having count(sc.sno)>2 order by sc.sno; --4.查詢每個學生的選課最高分和最低分,列出學號和分數 select sno, max(grade),min(grade) from sc group by sno; --5.查詢選課門數最多的2個學生的學號和姓名(有問題) select sno,num from (select sc.sno,count(sc.cno) num from sc group by sc.sno order by num desc) t where rownum<=2 --6.一句SQL查出所有課程成績最高和最低的學生及其分數 select * from (select sc.cno,sc.sno,sc.grade from (select cno,max(grade) gr from sc group by cno) t,sc where sc.cno = t.cno and t.gr = sc.grade order by cno) union all select * from (select sc.cno,sc.sno,sc.grade from (select cno,min(grade) gr from sc group by cno) t,sc where sc.cno = t.cno and t.gr = sc.grade order by cno) order by 1 asc,3 desc

實驗數據:student表、course表、sc表依次如下圖所示:

總結

以上是生活随笔為你收集整理的oracle:sql查询的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。