




全文預(yù)覽已結(jié)束
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(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的每一個(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ù)庫中所有居住街道和城市與其經(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)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 信息處理技術(shù)員職能測試試題及答案
- 2025屆貴陽市八下數(shù)學(xué)期末綜合測試模擬試題含解析
- 信息處理技術(shù)員技能試題及答案展示
- 軟件水平考試的改版動向與試題及答案
- 解密2025年網(wǎng)絡(luò)管理員考試試題及答案
- 營造積極氛圍的年度工作策略計(jì)劃
- 黑龍江省安達(dá)市一中學(xué)2025屆數(shù)學(xué)七下期末預(yù)測試題含解析
- 學(xué)校美術(shù)教育評估體系計(jì)劃
- 2025屆湖南省長沙市天心區(qū)部分學(xué)校八下數(shù)學(xué)期末考試模擬試題含解析
- 人工智能算法實(shí)際應(yīng)用試題及答案
- 經(jīng)濟(jì)類高等數(shù)學(xué)(下)期末考試模擬試卷1及參考答案
- 養(yǎng)老院老人興趣小組活動制度
- 《能力陷阱》課件
- 人教版小學(xué)四年級數(shù)學(xué)下冊課后練習(xí)試題大全
- 廣東省廣州市八區(qū)聯(lián)考2025屆高一物理第一學(xué)期期末教學(xué)質(zhì)量檢測試題含解析
- 煤礦調(diào)度工作內(nèi)容和方法
- 地坪漆售后服務(wù)措施
- 機(jī)動車駕駛培訓(xùn)理論科目一模擬考試題庫500題(含標(biāo)準(zhǔn)答案)
- 預(yù)防醫(yī)學(xué)練習(xí)題庫(附答案)
- 《讀書·目的和前提》《上圖書館》教學(xué)設(shè)計(jì)
- 農(nóng)民合作社資產(chǎn)負(fù)債表、盈余及盈余分配表、成員權(quán)益表
評論
0/150
提交評論