A. sql大于部门平均工资; 工资大于所在部门平均工资的人
SQL SERVER
select 工资 from 工资表 where 工资>(select AVG(工资) form 工资表 where 部门='部门') and 部门='部门';select 职员 from 工资表 where 工资>(select AVG(工资) form 工资表 where 部门='部门') and 部门='部门';select 职员,工资 from 工资表 where 工资>(select AVG(工资) form 工资表 where 部门='部门') 部门='部门';MySQL
select salary from salary where salary>(select AVG(salary) from salary where department='1') and department='1';select `name` from salary where salary>(select AVG(salary) from salary where department='1') and department='1';select `name`,salary from salary where salary>(select AVG(salary) from salary where department='1') and department='1';
希望对你能有所帮助。
B. 怎样用oraclel中的sql语句查询 emp表中工资大于平均工资的人员信息
select * from(
select emp.*,(select avg(sal+nvl(comm,0)) from emp) 平均工资 from emp)
where SAL+nvl(COMM,0)>平均工资;
或者
select * from emp where SAL+nvl(COMM,0)>(select avg(SAL+nvl(COMM,0)) from emp);
说明:工资包括 sal和comm(奖金),但是有的人没有奖金(NULL,为了处理这个NULL用到nvl函数),所以总工资是 [SAL+nvl(COMM,0)]
---
以上,希望对你有所帮助。
C. 列出各个部门中工资高于本部门的平均工资的员工数和部门号,并按部门号排序。用SQL语句详细介绍一下,谢
select a.deptno,count(*) from emp as a,
(select deptno,avg(sal) as avgsal from emp group by deptno) as b
where a.deptno=b.deptno
and a.sal>b.avgsal
group by a.deptno
order by a.deptno
表名为emp,deptno为部门号
(select deptno,avg(sal) as avgsal from emp group by deptno) as b
这个是查询每个部门的平均工资,并把这个结果集命名为b
然后关联emp表查询
where a.deptno=b.deptno
and a.sal>b.avgsal
这个就是在部门号相同的情况下,查找工资大于平均公司的人
最后count(*) 就是总人数,排序就正常order by 就OK
D. 查出每个部门大于平均工资的员工姓名,所在部门名称,工资的sql语句怎么写
这问题有歧义,是要查出每个部门大于所有人平均工资的还是查出每个部门大于所在部门所有人平均工资?
每个部门大于所有人平均工资的员工:
Select BM,YG From TB WHERE Salary>(Select Avg(Salary) From TB)
每个部门大于所在部门所有人平均工资的员工:
Select BM,YG From TB
Join (Select BM,Avg(Salary) as AvgSalary From TB
Group By BM) As Temp
On TB.BM=Temp.BM
where Salary>Temp.AvgSalary
E. 哪些员工的工资大于所在部门的平均工资用mysql查询语句
select t1.*, t2.s
from emp_hiloo t1 join (select deptno, avg(salary) s from emp_hiloo group by deptno) t2
on t1.deptno=t2.deptno
where t1.salary>t2.s
F. 编写一个PL/SQL块,输出所有比本部门平均工资高的员工 信息。
declare
begin
for v_emp in(
select dept.dname,X.b,emp.ename,emp.sal
from emp
join (select deptno a,round(avg(sal),2) b
from emp
group by deptno) X
on emp.deptno=X.a
and emp.sal>X.b
join dept
on emp.deptno=dept.deptno
order by emp.deptno desc)
loop
dbms_output.put_line('部门名称为:'||v_emp.dname||';平均薪资为:'||v_emp.b||
';高于该部门平均工资的员工为:'||v_emp.ename||';该员工工资为:'||v_emp.sal);
end loop;
end;
G. 查询工资大平均工资的所有员工姓名 SQL命令怎么写多谢帮忙
selecta.[员工姓名]
from[员工表]a,(selectsum(工资)as工资,count(工资)as人数from[员工表])b
wherea.[雇佣日期]<'1992-05-01'anda.工资>(b.工资/b.人数)
H. SQL大于部门平均工资; 工资大于所在部门平均工资的人
SQL SERVER
select 工资 from 工资表 where 工资>(select AVG(工资) form 工资表 where 部门='部门') and 部门='部门';select 职员 from 工资表 where 工资>(select AVG(工资) form 工资表 where 部门='部门') and 部门='部门';select 职员,工资 from 工资表 where 工资>(select AVG(工资) form 工资表 where 部门='部门') 部门='部门';MySQL
select salary from salary where salary>(select AVG(salary) from salary where department='1') and department='1';select `name` from salary where salary>(select AVG(salary) from salary where department='1') and department='1';select `name`,salary from salary where salary>(select AVG(salary) from salary where department='1') and department='1';
I. 怎样用oraclel中的sql语句查询 emp表中各部门工资大于本部门平均工资的人员信息
select * from emp a,(select avg(工资) gongzi from emp where 部门=‘本部门’) b
where a.工资 >b.gongzi
and a.部门<>'本部门'
--
第一你要取出,本部门的平均工资
第二你才能查出除了本部的人之外,工资大于本部门平均工资的人员
第一:取得平均工资
select avg(工资) from emp where 部门=‘本部门’
第二:使用上面取得的本部门的平均工资
select * from emp where 部门<>'本部门’and 工资>本部门的平均工资
J. plsql 查询工资高于本部门平均工资的员工号e_id,员工姓名e_name,部门号d_id,工资money,并按照部门降序
Select e_Id 员工号, e_Name 姓名, d_Id 部门号, Money 工资
From Employees
Where Money > (Select Avg(Money) From Employees)
Order By d_Id Desc