




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、word1. 找出所有为First bank corporation工作的雇员名字和居住城市;select e.employee name, cityfrom employee e, works wwhere w 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 wil
2、l onlylist those who earn more than $10,000 per annum from “First Bank Corporationalone.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 one
3、also.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 h
4、ave 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. 找出数据库中工资比Small bank corporation的每一个雇员都高的所有雇员;The following solution assumes that all
5、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 usi
6、ng 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, work
7、swhere works pany name = Small Bank Corporation andemp total salary.employee name = works.employee name)5. 假设一个公司可以在好几个城市有分部。找出位于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 s
8、ubsequent SQL versions.select T pany namefrom company Twhere (select R.cityfrom company Rwhere R pany name = T pany name)contains(select S.cityfrom company Swhere S pany name = Small Bank Corporation)Below is a solution using standard SQL.select S pany namefrom company Swhere not exists (select city
9、from companywhere company name = Small Bank Corporation)except(select cityfrom company Twhere S pany name = T pany 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. 找
10、出平均工资高于First bank corporation平均工资的所有公司;select company namefrom worksgroup by company namehaving avg (salary) (select avg (salary)from workswhere company name = First Bank Corporation)8. 找出数据库中所有居住街道和城市与其经理相同的雇员;Find all employees in the database who live in the same cities and on thesame streets as
11、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 pany name = S pany name)10. 找出工资
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 焦作空压机采购合同范本
- 风电运维总包合同协议书
- 甲方转乙方猎头合同范本
- 物料设计制作合同协议书
- 网络平台会员协议书范本
- 特种车辆雇佣协议书模板
- 美业学徒合同协议书模板
- 离婚法院调解协议书范本
- 项目文化墙设计合同范本
- 银行个性化分期协议合同
- 2025年中国冷镦钢线行业市场发展前景及发展趋势与投资战略研究报告
- 山东档案职称考试《档案基础理论》完整题(附答案)
- 2025年 吉林省长白山公安局警务辅助人员招聘考试试卷附答案
- 运动与青少年健康成长
- 2025至2030中国环氧活性稀释剂市场未来趋势及前景规划建议报告
- (新版)水利水电安全员考试题库及答案(含各题型)
- 研发项目过程管理制度
- 中学校园整体修缮工程项目可行性研究报告书
- 中国区域陆气耦合强度与极端高温关系的深度剖析
- DB61T-复齿鼯鼠饲养管理规范
- 出差报销标准协议
评论
0/150
提交评论