數(shù)據(jù)庫文件new實驗sql查詢?nèi)齙第1頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、實驗 5 SQL 查詢二【實驗?zāi)康摹空莆諗?shù)據(jù)匯總查詢及其相關(guān)子句的使用?!緦嶒灜h(huán)境】Sql server 2005【實驗重點及難點】啟動SQL Server 2005 查詢環(huán)境。涉及單表的簡單查詢。【實驗內(nèi)容】1 將實驗三的三張數(shù)據(jù)表還原到 SQL SERVER 2005 中。2 完成下列 SQL 查詢。并將代碼和結(jié)果到實驗中。1) 查詢不及格學生的學號、課程名、授課教師、成績的信息select Stu_no,c.Cou_no,Cou_teacher from SC,Course cwhere Grade60 and stu_no=sc.stu_no and c.Cou_no=sc.Cou_n

2、o2) 按學號分組匯總平均分高于70分的學生select Stu_no,c.Cou_no,Cou_teacherfrom SC,Course c,并按平均分的降序排列where Grade60 and stu_no=sc.stu_no and c.Cou_no=sc.Cou_no3) 使用子查詢求恰好有兩門課程不及格的學生信息select Stu_no,stu_name from Studentwhere Stu_no in(select Stu_no from SCwhere Grade=2)4)select使用子查詢查詢每門課程的最高分的學生*from SC bwhere grade=(s

3、elect MAX(grade) from SC awhere a.cou_no=b.Cou_no)5) 查詢每個學生及其選修課程的情況包括沒有選修課程的學生.select Student.Stu_no,stu_name,stu_sex,stu_age,stu_dept,cou_no,grade from Student left outer joinSC on (Student.Stu_no=sc.Stu_no)6) 求選修了a01或a02號而沒有選a03號課程的學生號select stu_no from SCwhere Cou_no=a01 or Cou_no=a02 exceptsele

4、ct stu_no from SCwhere Cou_no=a037) 查詢沒學過老師課的同學的學號、;select stu_no學號,stu_name from studentwhere stu_no not in(select s1.stu_nofrom Student s1,Course s2,SC s3 where s1.Stu_no=s3.Stu_noand s2.Cou_no=s3.Cou_noand Cou_teacher=8) 查詢學過)老師所教的所有課的同學的學號、;select Student.Stu_no 學號,stu_name from Studentwhere Stu

5、_no in( select Stu_no from SCwhere Cou_no in(select Cou_no from Coursewhere Cou_teacher=group by Stu_no)having COUNT(*)=(select COUNT(*)from Coursewhere Cou_teacher=)9) 查詢所有同學的學號、選課數(shù)、平均成績;select s.stu_no,s.stu_name,c.cou_name,sc.Gradefrom Student s,Course c,SCwhere s.Stu_no=sc.Stu_no and c.Cou_no=sc.Cou_no10) 統(tǒng)計列印各科成績,各分數(shù)段人數(shù):課程號,課程名,10085,8470,6960,590select cou_no,stu_no,sum(case,sum

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論