




全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 找出数据库中工资比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. 假设一个公司可以在好几个城市有分部。找出位于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. 找出数据库中所有居住街道和城市与其经理相同的雇员;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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 虚拟环境中的作弊预警-洞察与解读
- 汽车消费维权法律制度-洞察及研究
- 搬运设备智能化应用研究-洞察及研究
- 国际市场竞争格局演变-洞察及研究
- 海洋污染及其对人类健康的影响-洞察及研究
- 认知灵活性促进持续学习能力-洞察及研究
- 交通网络可靠性分析与提升-洞察及研究
- 草原水分对生物多样性影响研究-洞察及研究
- 2025年军供站财务招聘面试题预测实战演练与解析
- 2025年人力资源从业者手册招聘面试模拟题集萃
- 节后复工安全培训通讯课件
- 冰雪场馆建设施工方案
- 机械设备维修技术(第5版)(微课版)课件 第18讲 典型零部件的装配1
- 食用菌科普课件模板
- 各种引流管的固定及护理
- 核心高考高频688词汇(高考高频词汇)
- 国开2025年人文英语4写作形考答案
- 足球俱乐部会员权益规定
- AIGC艺术设计 课件全套 第1-8章 艺术设计的新语境:AI的介入 -AIGC艺术设计的思考与展望
- 冀教版(三起)(2024)三年级上册英语Unit 1 Lesson 1 Hello!教案
- 老年教育课程体系2025年优化与探究式教学模式实践报告
评论
0/150
提交评论