




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、實驗名稱實驗6實驗地點8-318實驗類型設(shè)計實驗學(xué)時1實驗日期2018-6-14 撰寫注意:版面格式已設(shè)置好(不得更改),填入內(nèi)容即可。一、 實驗?zāi)康?. 掌握系統(tǒng)數(shù)據(jù)類型的特點和功能。2. 掌握創(chuàng)建、修改表結(jié)構(gòu)的方法。3. 掌握插入、更新和刪除表數(shù)據(jù)的方法。二、 實驗內(nèi)容1.查詢所有班級的期末成績平均分,并按照平均分降序排序。2.查詢教師基本信息和教授課程信息,其中包括未分配課程的教師信息。3.查詢160501班級中選修了“韓晉升”老師講授的課程的學(xué)生學(xué)號、姓名、課程號和期末成績。4.查詢每門課程的課程號、課程名和選修該課程的學(xué)生人數(shù),并按所選人數(shù)升序排序。5.查詢兩門及以上課程的期末成績超
2、過80分的學(xué)生姓名及平均成績。6.查詢?nèi)雽W(xué)考試成績最高的學(xué)生學(xué)號、姓名和入學(xué)成績。7.查詢同時教授c05127號和c05109號課程的教師信息。8.查詢至少選修了姓名為“韓吟秋”的學(xué)生所選修課程中一門課程的學(xué)生學(xué)號和姓名。9.查詢所有教授c05127號課程的教師信息。10.查詢沒有被任何學(xué)生選修的課程編號、課程名稱和學(xué)分。11.查詢“C語言”課程期末成績比“電子技術(shù)”課程期末成績高的所有學(xué)生的學(xué)號和姓名。12查詢所有班級期末平均成績的最高分,并將其賦值給變量,通過PRINT語句輸出。13.使用游標(biāo)輸出學(xué)生姓名、選修課程名稱和期末考試成績。14.使用游標(biāo)統(tǒng)計每個學(xué)院教師所開設(shè)課程的選修率。15.
3、使用游標(biāo)計算學(xué)生期末成績的等級,并更新level列。三、 實驗環(huán)境1. 操作系統(tǒng):Windows XP2. 開發(fā)軟件:SQL Server 2008四、 提交文檔提交本實驗報告(電子版),文件名命名:學(xué)號 姓名實驗X:XXXXXXX.doc教師將批閱后(有分?jǐn)?shù))的全體學(xué)生實驗報告刻入一張光盤存檔,保證光盤可讀。五、 附:源代碼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(16122210009,c05103,87.00,82.00)insert into teacher(teacherno,tname,major,prof,department)values(t05001,韓晉升,軟件工程,教授,計算機(jī)學(xué)院)sele
5、ct * from classinsert into class(classno,classname,department,monitor)values(160501,計算機(jī),計算機(jī)學(xué)院,張三)select * from teach_classinsert into teach_class(teacherno,classno,courseno)values(t05001,160501,c05103)select * from teacherselect * from courseselect * from scoreselect classno,AVG(final) as 平均分 from s
6、tudent join scoreon student.studentno=score.studentno group by classnoorder by AVG(final) descselect teacher.*,cname from teacher left join teach_classon teacher.teacherno=teach_class.teachernoleft join course on teach_class.classno=course.courseno3.select student.studentno,sname,cname,final from st
7、udentjoin score on student.studentno=score.studentnojoin course on course.courseno=score.coursenowhere score.courseno in(select courseno from teach_class join teacher on teach_class.teacherno=teacher.teachernowhere tname=韓晉升)and classno=0905014.select course.courseno,cname,COUNT(studentno) fromscore
8、 join course on score.courseno=course.coursenogroup by course.courseno,cnameorder by COUNT(studentno) desc5.select sname,AVG(final) from score join student on score.studentno=student.studentnowhere final=80group by student.studentno,snamehaving COUNT(courseno)=26.select studentno,sname,point from st
9、udent wherestudentno=(select top 1 studentno from student order by point)7.select teacher.teacherno,tname,major ,prof,department from teacher join teach_class on teacher.teacherno=teach_class.teachernowhere courseno=c051278.select distinct student.studentno,sname from scorejoin student on score.stud
10、entno=student.studentnowhere courseno in(select courseno from score join student onscore.studentno=student.studentnowhere 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 ex
11、ists(select * from score where score.courseno=course.courseno)11.select student.studentno,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)
12、where ame=電子技術(shù) and sc1.studentno=sc2.studentnoand sc1.finalsc2.final)12.declare max numeric(6,2)select max=MAX(平均分) from (select classno as 班級號,AVG(final) as 平均分 from scorejoin student on (score.studentno=student.studentno)join course on (course.courseno=score.courseno)where final is not nullgr
13、oup by classno) tprint 所有班級期末平均成績的最高分:+cast(max as varchar(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
14、next from sc_cursor into sname,cname,finalprint 學(xué)生姓名 課程名稱 期末成績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 se
15、lect department,count(*) as 選修課數(shù) 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 ne
16、xt from curinto department,numset 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 course.courseno=score.coursenoopen stufetch stuinto sname,final,cnameif final=90print N
溫馨提示
- 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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 小鹿斑比成長之旅解讀
- 家庭農(nóng)場養(yǎng)殖技術(shù)推廣協(xié)議
- 時尚潮玩商品網(wǎng)絡(luò)銷售合作權(quán)責(zé)共擔(dān)協(xié)議
- 昆蟲記選讀教學(xué)教案:初中生物與自然知識結(jié)合學(xué)習(xí)指導(dǎo)
- 應(yīng)對項目管理中的風(fēng)險應(yīng)對策略
- 海底兩萬里的冒險之旅教案設(shè)計
- 養(yǎng)老服務(wù)機(jī)構(gòu)投資建設(shè)合同
- 高端設(shè)備采購與維護(hù)合同
- 花木蘭報國傳奇故事解讀
- 租賃戶外場地合同協(xié)議書
- 林木采伐安全協(xié)議書范本
- 招聘技巧話術(shù)培訓(xùn)
- 第九章 壓強(qiáng) 單元練習(xí)(含答案)-2024-2025學(xué)年人教版物理八年級下冊
- 職稱評定述職報告
- 2025-2030年中國黑豬行業(yè)市場發(fā)展?fàn)顩r及投資戰(zhàn)略研究報告
- 2024年醫(yī)師定期考核考題《臨床練習(xí)》
- 法律職業(yè)倫理知到智慧樹章節(jié)測試課后答案2024年秋溫州大學(xué)
- 英語-遼寧省大連市2024-2025學(xué)年高三上學(xué)期期末雙基測試卷及答案
- 2024安徽教師統(tǒng)一招聘考試《小學(xué)英語》試卷真題及答案
- 2024年考研數(shù)學(xué)(一)試題卷及答案
- 16-SC-提高附著式升降腳手架安全驗收一次合格率4:3
評論
0/150
提交評論