




已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
图1用两种方法建立一个新数据库HRM(也可任意取名),如上图所示(图1);鼠标右击数据库HRM- 数据查询,然后输入如下SQLServer语句:DepartmentID CHAR(3) NOT NULL PRIMARY KEY,DepartmentName CHAR(20) NOT NULL,Note TEXT)CREATE TABLE Employee(EmployeeID CHAR(6) NOT NULL PRIMARY KEY,NAME CHAR(10) NOT NULL,Birthday Datetime NOT NULL,SEX char(2) NOT NULL,Address CHAR(20),Zip CHAR(6),PhoneNumber CHAR(12),EmailAddress CHAR(30),DepartmentID CHAR(3) NOT NULL REFERENCES Departments(DepartmentID)ON DELETE NO ACTION)CREATE TABLE Salary(EmployeeID CHAR(6) NOT NULL REFERENCES Employee(EmployeeID)ON DELETE NO ACTION,Income FLOAT(8) NOT NULL,OutCome FLOAT(8) NOT NULL)在数据库HRM中,建立如下所示的三个表:Employee表, Departments表, Salary表对上节建立的表输入数据:Departments表:Employee表Salary表 如下图:练习下面简单的查询语句:a) 查询每个雇员的所有信息:输入语句select *from Employeeb) 查询每个雇员的地址和电话SELECT PhoneNumber,Address from Employeec) 查询EmployeeID为000001的雇员的地址和电话SELECT PhoneNumber,Address from Employeewhere EmployeeID=1001d) 查询女雇员地址和电话,并用AS子句将结果中各列的标题分别指定为“地址”和“电话”。SELECT 电话=PhoneNumber,地址=Address from Employeewhere SEX=0e) 计算每个雇员的实际收入。select 实际收入=Income-OutCome from Salaryselect DepartmentID from Employeewhere NAME like 王%f) 找出所有姓王的雇员的部门号3a) 查询每个雇员的情况及工资情况(工资=Income - Outcome)select Income-outcome,Employee.*from Employee,salarywhere Employee.EmployeeID=Salary.EmployeeIDb) 查询财务部工资在2200元以上的雇员姓名及工资情况select Name,Income-outcome as工资,DepartmentName from Departments,Salary,Employeewhere Departments.DepartmentID=Employee.DepartmentID and Salary.EmployeeID=Employee.EmployeeID and DepartmentName=财务部Group by DepartmentName,Income,Outcome,Employee.NAMEhaving (Income-outcome)2200c) 查询人力资源部雇员的最高和最低工资select MAX(Income-Outcome)as最高工资,min(Income-Outcome)as最低工资 from Salarywhere EmployeeID like 3%d) 将各雇员的情况按工资由低到高排列select income,employee.*from employee,salarywhere salary.employeeid=employee.employeeid order by income asce) 求各部门的雇员数select departments.departmentname,count(*)as员工数 from employee,departmentswhere employee.departmentid=departments.departmentidgroup by departments.departmentnamef找出所有在财务部和人力资源部工作的雇员的编号select DepartmentName,EmployeeID from Departments,Employeewhere Departments.DepartmentID=Employee.DepartmentIDgroup by DepartmentName,EmployeeIDhaving DepartmentName=财务部or DepartmentName=人力资源部g.和统计人力资源部工资在2500以上雇员的人数select count(*)as人力资源部以上的人数from departments,employee,salarywhere departments.departmentid=employee.departmentidand salary.employeeid=employee.departmentidand departmentname in(人力资源部)and income =2500h.求财务部雇员的总人数select count(*)as 财务部员工人数 from employee where departmentid in(1)i求财务部雇员的平均工资select Avg(Income-outcome)as平均工资,DepartmentName from Departments,Salary,Employeewhere Departments.DepartmentID=Employee.DepartmentID and Salary.EmployeeID=Employee.EmployeeIDgroup by DepartmentName,Departments.DepartmentIDhaving Departments.DepartmentName=财务部j查找比所有财务部的雇员工资都高的雇员的姓名 正确的为:select namefrom employee,salarywhere employee.employeeid=salary.employeeidand incomeall(select income from salary where employeeid in (select employeeid from employee,departments where departments.departmentid=employee.departmentidand departmentname=财务部)k查找财务部年龄不低于研发部所有雇员年龄的雇员的姓名select namefrom employee,departmentswhere birthdayall(select birthdayfrom employee where departmentid=2)and departments.departmentid=employee.departmentidand
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025福建生态工程职业技术学校招聘4人考前自测高频考点模拟试题及答案详解(历年真题)
- 2025年上半年内江市部分学校公开考试招聘教师、部分事业单位公开考试招聘工作人员笔试考前自测高频考点模拟试题及答案详解(名师系列)
- 2025年杭州市临安区部分医疗卫生事业单位招聘工作人员35人考前自测高频考点模拟试题及答案详解一套
- 2025年福建省红十字基金会人员招聘2人模拟试卷及答案详解(典优)
- 2025河南郑州航空港区某国企梅河芳邻选手村项目招聘12人考前自测高频考点模拟试题及答案详解参考
- 2025河南新乡市长垣市高章士学校招聘考前自测高频考点模拟试题及答案详解(有一套)
- 2025届春季特区建工集团校园招聘正式启动模拟试卷附答案详解(典型题)
- 2025福建三明机场发展集团有限公司招聘3人考前自测高频考点模拟试题及答案详解(夺冠)
- 2025湖南怀化新晃县公益性岗位人员招聘9人模拟试卷及1套完整答案详解
- 2025辽宁沈阳地铁集团有限公司所属公司拟聘用人员考前自测高频考点模拟试题及答案详解(考点梳理)
- 2025年云南交投集团校园招聘管理人员86人笔试参考题库附带答案详解
- 2025年6月上海市高考语文试题卷(含答案)
- 2025至2030中国汽车A柱行业项目调研及市场前景预测评估报告
- 2026年高考英语专题复习:必背近10高考英语高频词汇表
- 呼吸心跳骤停病人的护理查房
- 研究生教材SPSS统计软件应用
- 2025年部编版新教材三年级上册《9.犟龟》教案
- 2024-2025学年下学期高二英语外研社版期中必刷常考题之被动语态
- 人教版初中九年级全册英语单词表(完整版)
- 《《宫腔粘连多学科诊疗体系和效能评估标准》》
- 高教版中职物理(类)电子教案402第二节 全电路欧姆定律
评论
0/150
提交评论