![數(shù)據(jù)庫實(shí)驗(yàn)實(shí)驗(yàn)6_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-4/27/5d7e8a34-d547-494b-a351-de6e67f271c7/5d7e8a34-d547-494b-a351-de6e67f271c71.gif)
![數(shù)據(jù)庫實(shí)驗(yàn)實(shí)驗(yàn)6_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-4/27/5d7e8a34-d547-494b-a351-de6e67f271c7/5d7e8a34-d547-494b-a351-de6e67f271c72.gif)
![數(shù)據(jù)庫實(shí)驗(yàn)實(shí)驗(yàn)6_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-4/27/5d7e8a34-d547-494b-a351-de6e67f271c7/5d7e8a34-d547-494b-a351-de6e67f271c73.gif)
![數(shù)據(jù)庫實(shí)驗(yàn)實(shí)驗(yàn)6_第4頁](http://file3.renrendoc.com/fileroot_temp3/2022-4/27/5d7e8a34-d547-494b-a351-de6e67f271c7/5d7e8a34-d547-494b-a351-de6e67f271c74.gif)
![數(shù)據(jù)庫實(shí)驗(yàn)實(shí)驗(yàn)6_第5頁](http://file3.renrendoc.com/fileroot_temp3/2022-4/27/5d7e8a34-d547-494b-a351-de6e67f271c7/5d7e8a34-d547-494b-a351-de6e67f271c75.gif)
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、實(shí)驗(yàn)名稱實(shí)驗(yàn)6實(shí)驗(yàn)地點(diǎn)8-318實(shí)驗(yàn)類型設(shè)計(jì)實(shí)驗(yàn)學(xué)時(shí)1實(shí)驗(yàn)日期2018-6-14 撰寫注意:版面格式已設(shè)置好(不得更改),填入內(nèi)容即可。一、 實(shí)驗(yàn)?zāi)康?. 掌握系統(tǒng)數(shù)據(jù)類型的特點(diǎn)和功能。2. 掌握創(chuàng)建、修改表結(jié)構(gòu)的方法。3. 掌握插入、更新和刪除表數(shù)據(jù)的方法。二、 實(shí)驗(yàn)內(nèi)容1.查詢所有班級(jí)的期末成績平均分,并按照平均分降序排序。2.查詢教師基本信息和教授課程信息,其中包括未分配課程的教師信息。3.查詢160501班級(jí)中選修了“韓晉升”老師講授的課程的學(xué)生學(xué)號(hào)、姓名、課程號(hào)和期末成績。4.查詢每門課程的課程號(hào)、課程名和選修該課程的學(xué)生人數(shù),并按所選人數(shù)升序排序。5.查詢兩門及以上課程的期末成績超
2、過80分的學(xué)生姓名及平均成績。6.查詢?nèi)雽W(xué)考試成績最高的學(xué)生學(xué)號(hào)、姓名和入學(xué)成績。7.查詢同時(shí)教授c05127號(hào)和c05109號(hào)課程的教師信息。8.查詢至少選修了姓名為“韓吟秋”的學(xué)生所選修課程中一門課程的學(xué)生學(xué)號(hào)和姓名。9.查詢所有教授c05127號(hào)課程的教師信息。10.查詢沒有被任何學(xué)生選修的課程編號(hào)、課程名稱和學(xué)分。11.查詢“C語言”課程期末成績比“電子技術(shù)”課程期末成績高的所有學(xué)生的學(xué)號(hào)和姓名。12查詢所有班級(jí)期末平均成績的最高分,并將其賦值給變量,通過PRINT語句輸出。13.使用游標(biāo)輸出學(xué)生姓名、選修課程名稱和期末考試成績。14.使用游標(biāo)統(tǒng)計(jì)每個(gè)學(xué)院教師所開設(shè)課程的選修率。15.
3、使用游標(biāo)計(jì)算學(xué)生期末成績的等級(jí),并更新level列。三、 實(shí)驗(yàn)環(huán)境1. 操作系統(tǒng):Windows XP2. 開發(fā)軟件:SQL Server 2008四、 提交文檔提交本實(shí)驗(yàn)報(bào)告(電子版),文件名命名:學(xué)號(hào) 姓名實(shí)驗(yàn)X:XXXXXXX.doc教師將批閱后(有分?jǐn)?shù))的全體學(xué)生實(shí)驗(yàn)報(bào)告刻入一張光盤存檔,保證光盤可讀。五、 附:源代碼1.select studentno,AVG(final) as 平均分 from score group by studentno order by AVG(final)2.select * from teacherselect * from studentselect
4、 * from courseinsert into course(courseno,cname,ctype,period,credit)values('c05103','高等數(shù)學(xué)','必修',64,4.0) select * from scoreinsert into score(studentno,courseno,usually,final)values(,'c05103',87.00,82.00)insert into teacher(teacherno,tname,major,prof,department)values(
5、't05001','韓晉升','軟件工程','教授','計(jì)算機(jī)學(xué)院')select * from classinsert into class(classno,classname,department,monitor)values('160501','計(jì)算機(jī)','計(jì)算機(jī)學(xué)院','張三')select * from teach_classinsert into teach_class(teacherno,classno,courseno)values(&
6、#39;t05001','160501','c05103')select * from teacherselect * from courseselect * from scoreselect classno,AVG(final) as 平均分 from student join scoreon student.studentno=score.studentno group by classnoorder by AVG(final) descselect teacher.*,cname from teacher left join teach_class
7、on teacher.teacherno=teach_class.teachernoleft join course on teach_class.classno=course.courseno3.select student.studentno,sname,cname,final from studentjoin score on student.studentno=score.studentnojoin course on course.courseno=score.coursenowhere score.courseno in(select courseno from teach_cla
8、ss join teacher on teach_class.teacherno=teacher.teachernowhere tname='韓晉升')and classno='090501'4.select course.courseno,cname,COUNT(studentno) fromscore join course on score.courseno=course.coursenogroup by course.courseno,cnameorder by COUNT(studentno) desc5.select sname,AVG(final)
9、 from score join student on score.studentno=student.studentnowhere final>=80group by student.studentno,snamehaving COUNT(courseno)>=26.select studentno,sname,point from student wherestudentno=(select top 1 studentno from student order by point)7.select teacher.teacherno,tname,major ,prof,depar
10、tment from teacher join teach_class on teacher.teacherno=teach_class.teachernowhere courseno='c05127'8.select distinct student.studentno,sname from scorejoin student on score.studentno=student.studentnowhere courseno in(select courseno from score join student onscore.studentno=student.studen
11、tnowhere sname='韓吟秋')and sname!='韓吟秋'9.select * from teacher where teacherno in(select teacherno from teach_class wherecourseno='c05127')10.select courseno,cname,credit from course where not exists(select * from score where score.courseno=course.courseno)11.select student.stu
12、dentno,sname from score sc1 join studenton (sc1.studentno=student.studentno) join course c1 on(sc1.courseno=c1.courseno)where ame='c語言' and exists(select * from score sc2 join course c2 on(sc2.courseno=c2.courseno)where ame='電子技術(shù)' and sc1.studentno=sc2.studentnoand sc1.final>sc2.f
13、inal)12.declare max numeric(6,2)select max=MAX(平均分) from (select classno as 班級(jí)號(hào),AVG(final) as 平均分 from scorejoin student on (score.studentno=student.studentno)join course on (course.courseno=score.courseno)where final is not nullgroup by classno) tprint '所有班級(jí)期末平均成績的最高分:'+cast(max as varchar(
14、6)13.declare sname nchar(8),cname nchar(10),final numeric(6,2)declare sc_cursor cursor forselect sname,cname,finalfrom score join student on(score.studentno=student.studentno)join course on(score.courseno=course.courseno)open sc_cursorfetch next from sc_cursor into sname,cname,finalprint '學(xué)生姓名 課
15、程名稱 期末成績'print '-'while FETCH_STATUS=0beginprint sname+cname+cast(final as nchar(6)fetch next from sc_cursor into sname,cname,finalendclose sc_cursordeallocate sc_cursor14.declare department nchar(30),num int,avg floatdeclare cur cursor staticfor select department,count(*) as '選修課數(shù)
16、39; from classwhere class.classno in(select student.classno from student group by classno)group by departmentopen curfetch curinto department,numset avg=num/(select COUNT(*) from class where department=department)print departmentprint avgwhile FETCH_STATUS=0beginfetch next from curinto department,nu
17、mset avg=num/(select COUNT(*) from class where department=department)print departmentprint avgendclose curdeallocate cur15.declare sname nchar(30),cname nchar(30),final floatdeclare stu cursor staticforselect sname,final,cnamefrom student,score,coursewhere student.studentno=score.studentno and cours
18、e.courseno=score.coursenoopen stufetch stuinto sname,final,cnameif final>=90print N'優(yōu)'+sname+cnameelse if final>=80 and final<90print N'良'+sname+cnameelse if final>=70 and final<80print N'中'+sname+cnameelse if final>=60 and final<70print N'及'+sname+cnameelse if final<60print N'差'+sname+cnamewhile FETCH_STATUS=0beginfetch next from stuinto sname,final,cnameif final>=90print N'
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- GB/T 14124-2024機(jī)械振動(dòng)與沖擊固定建筑結(jié)構(gòu)的振動(dòng)振動(dòng)測量及對(duì)結(jié)構(gòu)影響評(píng)價(jià)的指南
- PB-22-8-Hydroxyisoquinoline-isomer-生命科學(xué)試劑-MCE-5052
- Lariciresinol-4-O-β-D-glucopyranoside-生命科學(xué)試劑-MCE-5846
- E3-Ligase-Ligand-linker-Conjugate-122-生命科學(xué)試劑-MCE-1944
- 二零二五年度航空航天產(chǎn)業(yè)融資合作協(xié)議書
- 二零二五年度用人單位與派遣公司國際化人才派遣服務(wù)協(xié)議
- 2025年度音樂制作與音樂版權(quán)許可合同
- 2025年度活動(dòng)板房銷售與臨時(shí)辦公場所租賃合同
- 二零二五年度商業(yè)地產(chǎn)貸款合同范本
- 2025年度飯店短期餐飲服務(wù)員勞務(wù)派遣協(xié)議
- 《春酒》琦君完整版
- 北師大版(2024新版)七年級(jí)上冊數(shù)學(xué)第四章《基本平面圖形》測試卷(含答案解析)
- 湖南省邵陽市武岡市2024屆高三上學(xué)期期中考試地理含答案解析
- 2022年內(nèi)分泌醫(yī)療質(zhì)量控制評(píng)價(jià)體系與考核標(biāo)準(zhǔn)
- 春節(jié)后復(fù)工安全教育培訓(xùn)考試試題及答案
- 寄宿制學(xué)校工作總結(jié)
- 小學(xué)數(shù)學(xué)6年級(jí)應(yīng)用題100道附答案(完整版)
- 2024年江蘇農(nóng)牧科技職業(yè)學(xué)院單招職業(yè)適應(yīng)性測試題庫含答案
- JT-T 1495-2024 公路水運(yùn)危險(xiǎn)性較大工程專項(xiàng)施工方案編制審查規(guī)程
- JT-T-390-1999突起路標(biāo)行業(yè)標(biāo)準(zhǔn)
- 2023年四川省成都市武侯區(qū)中考物理二診試卷(含答案)
評(píng)論
0/150
提交評(píng)論