




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、【精品文檔】如有侵權(quán),請(qǐng)聯(lián)系網(wǎng)站刪除,僅供學(xué)習(xí)與交流實(shí)驗(yàn)五 數(shù)據(jù)庫綜合查詢(學(xué)生).精品文檔.實(shí)驗(yàn)五 數(shù)據(jù)庫綜合查詢一、實(shí)驗(yàn)?zāi)康?. 掌握SELECT語句的基本語法和查詢條件表示方法;2. 掌握查詢條件種類和表示方法;3. 掌握連接查詢的表示及使用;4. 掌握嵌套查詢的表示及使用;5. 了解集合查詢的表示及使用。二、實(shí)驗(yàn)內(nèi)容1. 了解SELECT語句的基本語法格式和執(zhí)行方法;2. 以數(shù)據(jù)庫原理實(shí)驗(yàn)5數(shù)據(jù)為基礎(chǔ),請(qǐng)使用T-SQL 語句實(shí)現(xiàn)進(jìn)行相應(yīng)操作;3. 完成實(shí)驗(yàn)報(bào)告。三、實(shí)驗(yàn)步驟1. 查詢以數(shù)據(jù)_開頭,且倒數(shù)第3個(gè)字符為結(jié)的課程的詳細(xì)情況 select*from coursewhere Cn
2、ame like '數(shù)據(jù)_%結(jié)_'escape''2. 查詢名字中第2個(gè)字為陽的學(xué)生姓名和學(xué)號(hào)及選修的課程號(hào)、課程名; select sname 姓名,student.sno 學(xué)號(hào),o 課程號(hào),ame 課程名from student,course,sc where student.sno=sc.sno and o=o and sname like'_陽%'3. 列出選修了數(shù)學(xué)或者大學(xué)英語的學(xué)生學(xué)號(hào)、姓名、所在院系、選修課程號(hào)及成績; select student.sno,sname,sdept,cno,gradefrom student,scwh
3、ere student.sno=sc.sno and cno IN(select cno from course where cname='數(shù)學(xué)'OR CNAME='大學(xué)英語')4. 查詢?nèi)鄙俪煽兊乃袑W(xué)生的詳細(xì)情況; select*from student where not exists(select*from sc where sno=student.sno and grade is not null)select*from student where sno in(select sno from sc where grade is null)5. 查詢與
4、張力(假設(shè)姓名唯一)年齡不同的所有學(xué)生的信息; select b.*from student a,student b where a.sname='張力'and a.sage<>b.sage6. 查詢所選課程的平均成績大于張力的平均成績的學(xué)生學(xué)號(hào)、姓名及平均成績; select student.sno,sname,平均成績=avg(grade)from student,sc where sc.sno=student.sno group by student.sno,sname having avg(grade)>(select avg(grade)from s
5、c where sno=(select sno from student where sname='張力')7. 按照“學(xué)號(hào),姓名,所在院系,已修學(xué)分”的順序列出學(xué)生學(xué)分的獲得情況。其中已修學(xué)分為考試已經(jīng)及格的課程學(xué)分之和; select student.sno 學(xué)號(hào),sname 姓名,sdept 院系,已修學(xué)分=sum(credit)from student,course,sc where student.sno=sc.sno and o=o and grade>=60 group by student.sno,sname,sdept8. 列出只選修一門課程的學(xué)生的學(xué)號(hào)
6、、姓名、院系及成績; select student.sno 學(xué)號(hào),sname 姓名,sdept 院系,gradefrom student,sc where student.sno=sc.sno and sc.sno in(select sno from sc group by sno having count(cno)=1)9. 查找選修了至少一門和張力選修課程一樣的學(xué)生的學(xué)號(hào)、姓名及課程號(hào); select distinct student.*from student where sno in(select sno from sc where cno in(select cno from co
7、urse where cname='數(shù)據(jù)庫'or cname='數(shù)據(jù)結(jié)構(gòu)')10. 只選修“數(shù)據(jù)庫”和“數(shù)據(jù)結(jié)構(gòu)”兩門課程的學(xué)生的基本信息; select o,ame,x.sno,x.sname,grade from student x,sc y,course z where x.sno=y.sno and o=o11. 至少選修“數(shù)據(jù)庫”或“數(shù)據(jù)結(jié)構(gòu)”課程的學(xué)生的基本信息;select *from student,sc,coursewhere student.sno=sc.snoand o=oand cname='數(shù)據(jù)庫'orcname=
8、9;數(shù)據(jù)結(jié)構(gòu)'12. 列出所有課程被選修的詳細(xì)情況,包括課程號(hào)、課程名、學(xué)號(hào)、姓名及成績; select o,ame,student.sno,student.sname,gradefrom student,sc,coursewhere student.sno=oand o=o13. 查詢只被一名學(xué)生選修的課程的課程號(hào)、課程名; select cno,cnamefrom coursewhere cno in(select cnofrom scgroup by cnohaving count(sno)=1)14. 使用嵌套查詢列出選修了“數(shù)據(jù)結(jié)構(gòu)”課程的學(xué)生學(xué)號(hào)和姓名; select sn
9、o,snamefrom studentwhere sno in(select snofrom scwhere cno in(select cnofrom coursewhere cname='數(shù)據(jù)結(jié)構(gòu)')15. 使用嵌套查詢查詢其它系中年齡小于CS系的某個(gè)學(xué)生的學(xué)生姓名、年齡和院系; select sname,sage,sdeptfrom studentwhere sage<(select max(sage)from studentwhere sdept='cs'and sdept<>'cs')16. 使用ANY、ALL 查詢,
10、列出其他院系中比CS系所有學(xué)生年齡小的學(xué)生; select sname,sagefrom studentwhere sage<any(select min(sage)from studentwhere sdept='cs'and sdept<>'cs')select sname,sagefrom studentwhere sage<all(select sagefrom studentwhere sdept='cs'and sdept<>'cs')17. 分別使用連接查詢和嵌套查詢,列出與張力在一個(gè)院系的學(xué)生的信息; select*from studentwhere sdept=(select sdeptfrom studentwhere sname='張力')18. 使用集合查詢列出CS系的學(xué)生以及性別為女的學(xué)生名單; select snamefrom studentwhere sdept='cs'unionselect snamefrom studentwhere ssex='女'19. 使用集合查詢列出CS系的學(xué)生與年齡不大于19歲的學(xué)生的交集、差集; select*from studentwhere sdept='cs
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025銷售合同范本格式
- 醫(yī)養(yǎng)融合公共衛(wèi)生應(yīng)急中的新模式探索
- 2025關(guān)于白酒類網(wǎng)絡(luò)廣告宣傳合同范本
- 2025煤炭買賣合同范本
- 醫(yī)療科技趨勢下的APP交互革新之路
- 行政管理的決策模型試題及答案
- 2025年行政管理語文核心試題及答案
- 執(zhí)業(yè)護(hù)士實(shí)踐中的案例學(xué)習(xí)題及答案2025
- 2025年護(hù)士執(zhí)業(yè)考試綜合復(fù)習(xí)試題及答案
- 2025技術(shù)授權(quán)合同模板
- 采購文員考試試題及答案
- 《智能家居系統(tǒng)介紹》課件
- 隆德縣招聘城市社區(qū)工作者筆試真題2024
- 北京市一零一中學(xué)2024-2025學(xué)年高三適應(yīng)性調(diào)研考試語文試題含解析
- 貴州省往年氣象局筆試公共基礎(chǔ)題庫
- 模具維護(hù)保養(yǎng)培訓(xùn)
- 維護(hù)國家文化安全
- 兒童流行性感冒疫苗預(yù)防和抗病毒藥物應(yīng)用的實(shí)踐指南(2024版)解讀課件
- 高效時(shí)間管理培訓(xùn)的技巧
- 2025年河南鄭州航空港科創(chuàng)投資集團(tuán)有限公司招聘筆試參考題庫附帶答案詳解
- (一模)青島市2025年高三年級(jí)第一次適應(yīng)性檢測英語試卷(含標(biāo)準(zhǔn)答案)+聽力材料
評(píng)論
0/150
提交評(píng)論