SQL数据库系统SQL补充习题2答案

SQL数据库系统SQL补充习题2答案

ID:42326397

大小:38.50 KB

页数:5页

时间:2019-09-12

SQL数据库系统SQL补充习题2答案_第1页
SQL数据库系统SQL补充习题2答案_第2页
SQL数据库系统SQL补充习题2答案_第3页
SQL数据库系统SQL补充习题2答案_第4页
SQL数据库系统SQL补充习题2答案_第5页
资源描述:

《SQL数据库系统SQL补充习题2答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、1.找出所有为Firstbankcorporation工作的雇员名字和居住城市;selecte.employeename,cityfromemployeee,workswwherew.companyname=’FirstBankCorporation’andw.employeename=e.employeename2.找出所有为Firstbankcorporation工作且薪金超过1万元的雇员名字、居住街道和城市;Ifpeoplemayworkforseveralcompanies,thefollo

2、wingsolutionwillonlylistthosewhoearnmorethan$10,000perannumfrom“FirstBankCorporation”alone.select*fromemployeewhereemployeenamein(selectemployeenamefromworkswherecompanyname=’FirstBankCorporation’andsalary¿10000)Asinthesolutiontothepreviousquery,wecanu

3、seajointosolvethisonealso.3.找出所有不为Firstbankcorporation工作的雇员;Thefollowingsolutionassumesthatallpeopleworkforexactlyonecompany.selectemployeenamefromworkswherecompanyname_=’FirstBankCorporation’Ifoneallowspeopletoappearinthedatabase(e.g.inemployee)butnot

4、appearinworks,orifpeoplemayhavejobswithmorethanonecompany,thesolutionisslightlymorecomplicated.selectemployeenamefromemployeewhereemployeenamenotin(selectemployeenamefromworkswherecompanyname=’FirstBankCorporation’)4.找出数据库中工资比Smallbankcorporation的每一个雇员

5、都高的所有雇员;Thefollowingsolutionassumesthatallpeopleworkforatmostonecompany.selectemployeenamefromworkswheresalary>all(selectsalaryfromworkswherecompanyname=’SmallBankCorporation’)Ifpeoplemayworkforseveralcompaniesandwewishtoconsiderthetotalearningsofeachp

6、erson,theproblemismorecomplex.Itcanbesolvedbyusinganestedsubquery,butweillustratebelowhowtosolveitusingthewithclause.withemptotalsalaryas(selectemployeename,sum(salary)astotalsalaryfromworksgroupbyemployeename)selectemployeenamefromemptotalsalarywheret

7、otalsalary>all(selecttotalsalaryfromemptotalsalary,workswhereworks.companyname=’SmallBankCorporation’andemptotalsalary.employeename=works.employeename)5.假设一个公司可以在好几个城市有分部。找出位于Smallbankcorporation所有所在城市的所有公司;Thesimplestsolutionusesthecontainscomparisonw

8、hichwasincludedin theoriginalSystemRSequellanguagebutisnotpresentinthesubsequentSQLversions.selectT.companynamefromcompanyTwhere(selectR.cityfromcompanyRwhereR.companyname=T.companyname)contains(selectS.cityfromcompanySwhereS.companynam

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。