




全文預(yù)覽已結(jié)束
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
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工作且薪金超過1萬元的雇員名字、居住街道和城市;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ù)庫中工資比Small bank corporation的每一個雇員都高的所有雇員;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è)一個公司可以在好幾個城市有分部。找出位于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ù)庫中所有居住街道和城市與其經(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. 本站所有資源如無特殊說明,都需要本地電腦安裝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)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 二手房出售合同的法律表述
- 健身中心門市租賃合同
- 2025年度智慧城市建設(shè)項目入股協(xié)議書
- 二零二五年度房產(chǎn)中介傭金結(jié)算合同范本規(guī)范傭金收取
- 二零二五年度區(qū)塊鏈技術(shù)合伙人股權(quán)分配與產(chǎn)業(yè)應(yīng)用協(xié)議
- 二零二五年度環(huán)保能源項目投資合作合同協(xié)議
- 2025年度生態(tài)公園地面硬化與景觀設(shè)計合同
- 2025年度酒店客房預(yù)訂與情侶浪漫晚餐套餐合同
- 合肥市2025年度勞動合同(含員工職業(yè)發(fā)展規(guī)劃)
- 2025年數(shù)字仿真計算機合作協(xié)議書
- 基于語文核心素養(yǎng)的初中語文綜合性學(xué)習(xí)教學(xué)策略研究
- 工藝部述職報告
- 廣東中考美術(shù)知識點
- 臨床科室科研用藥管理制度
- 多層光柵結(jié)構(gòu)的防偽技術(shù)研究
- 《國有企業(yè)采購操作規(guī)范》【2023修訂版】
- 五年級語文下冊第五單元【教材解讀】-【單元先導(dǎo)課】
- DQ-廠房設(shè)施設(shè)計確認(rèn)方案
- 常用中藥飲片介紹PPT幻燈片
- 各國鋼材牌號對照大全
- MSA-測量系統(tǒng)分析模板
評論
0/150
提交評論