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