版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、觸發(fā)時(shí)間:有 insert,update,delete3) ?:selects#觸發(fā)時(shí)間:有 insert,update,delete3) ?:selects#,snfromswhereS#in(selectS#fromc,scwherec.c#=sc.c#and基(2) 使用標(biāo)準(zhǔn) SQL和所答:selectsn,sdfroms,scwheres.s#=sc.s#and(3) 使用標(biāo)準(zhǔn) SQL?答:selectsn,sdfromswheres#notin(selectsfromscwhere 答:select 學(xué)員人數(shù)=count(distinctsfrom(5) 查詢選修課程超過(guò) 5? 值。
2、不能把任何值與一個(gè) 個(gè)ISNULL檢查系統(tǒng)的I/O令A(yù)、MODIFY、MODIFYSTRUCTUREC、ALTERTABLED、ALTER 值。不能把任何值與一個(gè) 個(gè)ISNULL檢查系統(tǒng)的I/O令A(yù)、MODIFY、MODIFYSTRUCTUREC、ALTERTABLED、ALTER令A(yù)、DROP、ALTERTABLEC、DELETETABLED、60語(yǔ)句的功能DELETEFROMSAS60B、S表大于60歲C、刪除S 表 D、刪除S列 A、選擇工作區(qū)語(yǔ)句 B、數(shù)據(jù)查詢語(yǔ)句 C、選擇標(biāo)準(zhǔn)語(yǔ)句 DSQL語(yǔ)言語(yǔ)言A、層次數(shù)據(jù)庫(kù) B、網(wǎng)絡(luò)數(shù)據(jù)庫(kù) C、關(guān)系數(shù)據(jù)庫(kù) D在SQL中,刪除視圖 命令 命令 SQ
3、L80:selectdistinctnamefromnamenotin(selectdistinctnamefromwhere123學(xué)生表 如下::deletetablenamewhere 自動(dòng)by 學(xué)號(hào),一個(gè)叫 teamname4a,b,c,d答: from team a, team b123學(xué)生表 如下::deletetablenamewhere 自動(dòng)by 學(xué)號(hào),一個(gè)叫 teamname4a,b,c,d答: from team a, team b where 12341234:select(s
4、electamountfrom (selectamountfrom (selectamount(selectamountaaamwhere aaamwheremonth=2 aaamwheremonth=3 aaamwhere andm.year=aaa.year)asandm.year=aaa.year)asm2, andm.year=aaa.year)asm3, and m.year=aaa.year) as m4fromgroupbyABkeyvalue 兩個(gè)字段,如果BkeyABA 中對(duì)應(yīng)的valuebaSQL1,:Createtablestu,家庭地址 ,:Altertablestu
5、add 學(xué)歷 :Altertablestudropcolumn 家庭地址1A221234562SQL1,:Createtablestu,家庭地址 ,:Altertablestuadd 學(xué)歷 :Altertablestudropcolumn 家庭地址1A221234562B 211193C231104D18114 ostuvalues(2,B,21,男,119 5:Updatestuset 學(xué)歷=大專 like6) 刪除學(xué)生表的數(shù)據(jù),C:Delectfromstulike7來(lái),學(xué)號(hào) fromstu22and 學(xué)歷=大專825:Selecttop25percent*from9) 查詢出所有學(xué)生的,
6、,fromstuorder10) 按照6) 刪除學(xué)生表的數(shù)據(jù),C:Delectfromstulike7來(lái),學(xué)號(hào) fromstu22and 學(xué)歷=大專825:Selecttop25percent*from9) 查詢出所有學(xué)生的,,fromstuorder10) 按照:Select)fromstugroupcreatetable(deptnovarchar(10)primarykey, dname varchar(10)createtableemp empnovarchar(10)primarykey, ename varchar(10),job varchar(10), mgrvarchar(1
7、0), sal varchar(10),deptnovarchar(10)droptabledept; droptable odeptvalues1odeptvalues2odeptvalues3oempvalues oempvalues oempvalues oempvalues oempvalues oempvalues oempvalues select*fromselect*fromSQL(1oempvalues oempvalues oempvalues oempvalues oempvalues select*fromselect*fromSQL(1:selectdeptnoas
8、emp group by deptno;部門(mén)號(hào),max(salas 最高工資,min(sal)as 最低工資 (2 為:selectmax(sal)as 最高工資,min(sal)as 最低工資,deptnoas 部門(mén)號(hào) fromempjob=clerkgroupby(3:selectb.deptnoas 部門(mén)號(hào),max(sal)as 最高工資,min(sal)as 最低工資 fromempasb wherejob=clerkandselectmin(sal)fromempasawherea.deptno=b.deptno)(selectavg(a.sal)fromempasawherea.d
9、eptno=b.deptno)orderby(11、對(duì)于 :selecta.deptnoas 部門(mén)號(hào),count(a.salas 員工數(shù) fromempaswhere a.sal(select avg(b.sal) from emp as bwhere a.deptno=b.deptno) group by a.deptno by(12:selectcount(a.empnoas 員工數(shù),a.deptnoas 部門(mén)號(hào),avg(sal)as 平均工資fromempasawhere(selectcount(c.empno)fromempascwherec.deptno=a.deptnoand c.
10、sal(select avg(sal) from emp as b where c.deptno=b.deptno)1groupbya.deptnoorderby(13:selecta.deptnoas 部門(mén)號(hào),a.enameempas whereb.sala.salas 人數(shù) fromempas,a.salas 工資,(selectcount(b.enamewhere(selectcount(b.ename)fromempasbwhereTableXCode、 Name、 Age、 其中 CodeTableYCode、 Class、Score, 其中 CodeClass 為主鍵。兩表Code
11、NameAgeCodeClass22212022數(shù)學(xué) 計(jì)算機(jī) 計(jì)算機(jī) 數(shù)學(xué) (1:select*fromTableXwherenamelikeorderby(2:select*fromtableXwherecodeinselectcodefromtableYWEHREclassand score 60)(3:,b.class,b.scorefromtableXa,tableYbwhere(4:,b.class,b.scorefromtableXfull(2:select*fromtableXwherecodeinselectcodefromtab
12、leYWEHREclassand score bthenaelsebend), (case when bc then b esle c end)from請(qǐng)取出 tb_send 表期(SendTime?(SendTime 字段為:select*fromtbwhere一個(gè)表中的Id1:selectid,Count(*)fromtbgroupbyidhaving2:select*from(selectcount(ID)ascountfromtablegroupbyID)Twhere:select*fromscore where s_name not in (selects_namefromscore
13、 where score=60)、課程、分?jǐn)?shù)60:select*fromscore where s_name not in (selects_namefromscore where score=60)、課程、分?jǐn)?shù)6032:select 名稱 from 商品表 group名稱 havingavg600:select 準(zhǔn)考證號(hào) from 高考信息表 group準(zhǔn)考證號(hào) havingsum600:select 準(zhǔn)考證號(hào) from 高考信息表 whereidgenderMFFFM里:selectgender,count(id)600:select 準(zhǔn)考證號(hào) from 高考信息表 whereidgend
14、erMFFFM里:selectgender,count(id)fromclubgroupbyID(numberName(varchar123456acID(numberName(varchar2125SQLa:deletefromteamwhereidnot(select min(a1.id) from team a1 =deletefromteamwhereidnotin selectmin(id)fromteamgroupbynamecourse張青 化學(xué):select*fromstudentwherenamein (select name fro
15、m studentwherenamelikegroupbynamehavingavg(score)create張青 化學(xué):select*fromstudentwherenamein (select name from studentwherenamelikegroupbynamehavingavg(score)createtable(department)otesttable1values(otesttable1values(otesttable1values(id123createtable(,name)otesttable2values(1otesttable2values(1otestt
16、able2values(2otesttable2values(3otesttable2values(4otesttable2values(5SQLiddptIDdepartment1234511234select t2.id,t2.dptID,t1.department, from testtable2 t2left jointesttable1t1on SELECT t2.id , t2.dptID, ) dptName, FROM t1rightesttable2t2ont2.dptID=A(ID,Name3140createtable(select t2.id
17、,t2.dptID,t1.department, from testtable2 t2left jointesttable1t1on SELECT t2.id , t2.dptID, ) dptName, FROM t1rightesttable2t2ont2.dptID=A(ID,Name3140createtable(varchar)SQL:selecttop10 * from Awhere ID (select max(ID) from (select top 30ID fromA byid)T)orderbyA(ID,NameID:createtable(,
18、varchar)AAAAAAAAby有表,name,createtablenamevarchar)oempoempoempoempoempoempoempoempoempoempoempoempoempoempoempoempoempoempoempoempoempoempoempoempoemp編寫(xiě) ?:selectid,name,age from empwhere name in(select name from empgroupby havingcreatetablenamevarchar(20), )oempoempoempoemp1:selectdistinct*2:selectna
19、me,agefromempgroupbycreatetableName varchar(25), CNamevarchar(25)ocoursevaluesocoursevaluesocoursevaluesocoursevaluesocoursevaluesocoursevaluesocoursevaluesocoursevaluesocoursevaluesocoursevaluesocoursevaluesocoursevaluesocoursevaluesocoursevaluesocoursevaluesSQL:select*fromwherenameocoursevaluesoco
20、ursevaluesocoursevaluesocoursevaluesSQL:select*fromwherenamein(selectnamefromcoursewhereCNameingroupbyname having count(*)=3)andnamenotin(selectnamefromcoursegroupbynamehaving問(wèn)題二:同時(shí)選了數(shù)學(xué),物理,語(yǔ)文的學(xué)生, 查詢結(jié)果如下,寫(xiě)出相應(yīng)SQL:select*fromwherenamein(selectnamefromcoursewhereCNameingroupbyname having count(*)=3)F(FI
21、DFLASFSSEcreatetableF3FID varchar(20), FLASSvarchar(20), )F3valuesF3values F3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3values:selectF3.FLASS,Max(FSSCORE)fromF
22、3groupbyFLASShavingcount(*)F3valuesF3valuesF3valuesF3valuesF3valuesF3valuesF3values:selectF3.FLASS,Max(FSSCORE)fromF3groupbyFLASShavingcount(*)createtableTeachers,T_NAME)createtableStudents,S_NAME)createtableClasses,C_NAME)TeachersTeachersTeachersTeachersTeachersStudentsStudentsStudentsStudentsStude
23、ntsStudentsStudentsStudentsStudentsStudentsStudentsStudentsStudentsStudentsStudentsStudents StudentsStudentsStudentsStudents :selectfromTeachersT_ID,count(*)asxfromClasseswhereC_Name=小班groupbyT_ID)T1, T_ID,count(*) as xfrom Classeswhere C_Name=大班 group by T_ID) T2whereandT1.T_ID=T2.T_IDand有兩張表:a 部門(mén)表
24、 b 員工表aid)b employee- 員工名稱)createtableNamevarchar)createtable,Namevarchar)odepartmentsvalueso)b employee- 員工名稱)createtableNamevarchar)createtable,Namevarchar)odepartmentsvaluesodepartmentsvaluesodepartmentsvaluesodepartmentsvaluesodepartmentsvaluesoemployeesvaluesoemployeesvaluesoemployeesvaluesoemp
25、loyeesvaluesoemployeesvalues oemployeesvaluesoemployeesvaluesoemployeesvaluesoemployeesvaluesoemployeesvaluesoemployeesvalues oemployeesvaluesoemployeesvalues:select b.id,a.Name,count(b.id)as employeesbona.id=b.idgroupbyfrom departments a left year2000200120022003yearsalary 2000200120022003SQLcreate
26、table)selectyearsalary 2000200120022003SQLcreatetable)select*fromot_salaryot_salaryot_salaryot_salary:select year, (select sum(salary) from t_salary b where b.year =2018-01-0100:00:00 and user_id = U002orderbyborrow_time(58:select*fromuserwherephonelike:selectcount(*)from:selectdistinctuser_idfrombo
27、rrow_log where borrow_bike_stop_id = R002orreturn_bike_stop_id=20171115(9:select*fromuserwherenotect1fromrecharge_logwherea.user_id=andb.recharge_time=erval -90(10:select*fromuserwherenotect1fromborrow_logwherea.user_id=andb.borrow_time=erval -90(11 borrow_bike_stop_id,count(distinctuser_id)fromwhere borrow_time = date_add(now(),erval-180day) group by borrow_bike_stop_id;(12 return_bike_stop_id,count(distinctuser_id)fromwhere borrow_time = date_add(now(),erval-180day) and return_bike_stop_id groupby(13a.borrow_bike_stop_id,max(b.stop_na
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年度公司車(chē)輛租賃協(xié)議樣本
- 2024道路安全員招聘協(xié)議樣本
- 2024年聘用協(xié)議規(guī)范化樣本
- 2023-2024學(xué)年鄭州市高三下學(xué)期5月月考數(shù)學(xué)試題(A卷)
- 2024安全生產(chǎn)與環(huán)保綜合管理協(xié)議
- 二手車(chē)交易過(guò)戶協(xié)議范本2024
- 2024年度專項(xiàng)宣傳品訂制協(xié)議
- 2024年項(xiàng)目實(shí)施階段服務(wù)協(xié)議范本
- 天津市河北區(qū)2024-2025學(xué)年高二上學(xué)期11月期中英語(yǔ)試題(無(wú)答案)
- 2024專業(yè)桃苗采購(gòu)及種植服務(wù)協(xié)議
- 破產(chǎn)法PPT課件
- 金融衍生工具ppt課件
- 光電效應(yīng)測(cè)定普朗克常數(shù).ppt
- “讓學(xué)引思”高效課堂推進(jìn)策略的研究
- 《培訓(xùn)機(jī)構(gòu)教師薪酬制度》
- 點(diǎn)子圖方格紙合計(jì)
- 乘法的故事(小學(xué)二年級(jí)課前小故事).ppt
- 《骨盆重要性》PPT課件.ppt
- WHO癌痛的三階梯止痛的原則
- 第二節(jié)絡(luò)合物的分子軌道理論
- 高等電力系統(tǒng)分析
評(píng)論
0/150
提交評(píng)論