SQL数据库题

来源:百度知道 编辑:UC知道 时间:2024/09/20 23:26:14
SQL数据库题
员工表employee 编号 emploueeId 员工姓名name 部门号deptId 工资wages
要求 1查询第5行数据 2统计每个部门的员工数 3查询员工信息 条件: 工资>自己所在部门平均工资
(题目本来就什么都没有给,小弟不知道该什么写 请大虾赐教)

1:select * from employee where id=5
2:select a.deptld as 部门号,count(b.deptld) as 员工数 from (select distinct deptld from employee) as a inner join (select * from employee) as b on a.deptld=b.deptld group by a.deptld
3:select a.name from (select * from employee) as a inner join (
select deptld ,avg(wages) as 平均工资 from employee group by deptld) as b on a.deptld=b.deptld and a.wages >b.平均公资

1:select top 1 * from employee where id in (select top 5 * from employee order by id desc )

2:select count(*) from empoyee group by deptld order by count(*)

3:select * from employee where wages > (select avg(wages) from employee where deptld = "所在部门")