




全文預(yù)覽已結(jié)束
下載本文檔
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1. 找出所有為First bank corporation工作的雇員名字和居住城市;select e.employee name, cityfrom employee e, works wwhere pany name = First Bank Corporation andw.employee name = e.employee name2. 找出所有為First bank corporation工作且薪金超過(guò)1萬(wàn)元的雇員名字、居住街道和城市;If people may work for several companies, the following solution will onlylist those who earn more than $10,000 per annum from “First Bank Corporation”alone.select *from employeewhere employee name in(select employee namefrom workswhere company name = First Bank Corporation and salary 10000)As in the solution to the previous query, we can use a join to solve this onealso.3. 找出所有不為First bank corporation工作的雇員;The following solution assumes that all people work for exactly one company.select employee namefrom workswhere company name _= First Bank CorporationIf one allows people to appear in the database (e.g. in employee) but notappear in works, or if people may have jobs with more than one company,the solution is slightly more complicated.select employee namefrom employeewhere employee name not in(select employee namefrom workswhere company name = First Bank Corporation)4. 找出數(shù)據(jù)庫(kù)中工資比Small bank corporation的每一個(gè)雇員都高的所有雇員;The following solution assumes that all people work for at most one company.select employee namefrom workswhere salary all(select salaryfrom workswhere company name = Small Bank Corporation)If people may work for several companies and we wish to consider thetotal earnings of each person, the problem is more complex. It can be solvedby using a nested subquery, but we illustrate below how to solve it usingthe with clause.with emp total salary as(select employee name, sum(salary) as total salaryfrom worksgroup by employee name)select employee namefrom emp total salarywhere total salary all(select total salaryfrom emp total salary, workswhere pany name = Small Bank Corporation andemp total salary.employee name = works.employee name)5. 假設(shè)一個(gè)公司可以在好幾個(gè)城市有分部。找出位于Small bank corporation所有所在城市的所有公司;The simplest solution uses the contains comparison which was included inthe original System R Sequel language but is not present in the subsequent SQL versions.select T.company namefrom company Twhere (select R.cityfrom company Rwhere R.company name = T.company name)contains(select S.cityfrom company Swhere S.company name = Small Bank Corporation)Below is a solution using standard SQL.select S.company namefrom company Swhere not exists (select cityfrom companywhere company name = Small Bank Corporation)except(select cityfrom company Twhere S.company name = T.company name)6. 找出雇員最多的公司;select company namefrom worksgroup by company namehaving count (distinct employee name) = all(select count (distinct employee name)from worksgroup by company name)7. 找出平均工資高于First bank corporation平均工資的所有公司;select company namefrom worksgroup by company namehaving avg (salary) (select avg (salary)from workswhere company name = First Bank Corporation)8. 找出數(shù)據(jù)庫(kù)中所有居住街道和城市與其經(jīng)理相同的雇員;Find all employees in the database who live in the same cities and on thesame streets as do their managers.select P.employee namefrom employee P, employee R, manages Mwhere P.employee name = M.employee name andM.manager name = R.employee name andP.street = R.street and P.city = R.city9. 找出工資高于其所在公司雇員平均工資的所有雇員;Find all employees who earn more than the average salary of all employeesof their company.The following solution assumes that all people work for atmost one company.select employee namefrom works Twhere salary (select avg (salary)from works Swhere T.company name = S.company name)10. 找出
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 論詞匯銜接在語(yǔ)篇教學(xué)中的運(yùn)用
- 小熊的奇幻森林冒險(xiǎn)童話作文(4篇)
- 某超市成果宣傳規(guī)定
- 穿越星空之旅想象作文(7篇)
- 超市與生鮮電商平臺(tái)合作備忘錄
- 奇思妙想:如果我是一朵云作文12篇范文
- 2025年采購(gòu)師(高級(jí))考試試卷:采購(gòu)團(tuán)隊(duì)管理與供應(yīng)鏈協(xié)同效應(yīng)試題
- 2025年電子商務(wù)師(高級(jí))考試試卷:電子商務(wù)平臺(tái)數(shù)據(jù)分析實(shí)戰(zhàn)
- 2025年地區(qū)公務(wù)員證監(jiān)會(huì)計(jì)類專業(yè)試卷:會(huì)計(jì)信息系統(tǒng)與審計(jì)技術(shù)試題
- 全職員工在職表現(xiàn)及信息證明(7篇)
- 口腔粘結(jié)系統(tǒng)
- 2025至2030年中國(guó)尼龍?jiān)偕闲袠I(yè)市場(chǎng)運(yùn)行格局及發(fā)展前景研判報(bào)告
- 德克士的區(qū)域擴(kuò)張計(jì)劃
- 網(wǎng)絡(luò)行為分析-第1篇-洞察及研究
- 修理工安全試題及答案
- 輔導(dǎo)員職業(yè)資格考試2025年試題及答案
- 2025年傳統(tǒng)食品工業(yè)化生產(chǎn)智能化生產(chǎn)線改造報(bào)告
- 園林綠化工高級(jí)考試試題及答案
- 2025河南省豫地科技集團(tuán)社會(huì)招聘169人筆試參考題庫(kù)附帶答案詳解析集合
- 2025年一年級(jí)語(yǔ)文1-8單元期末考試復(fù)習(xí)基礎(chǔ)知識(shí)點(diǎn)默寫(xiě)清單(有答案)
- 2025年重癥醫(yī)學(xué)科ICU護(hù)理質(zhì)量控制計(jì)劃
評(píng)論
0/150
提交評(píng)論