sql查询某个条件 [英] sql query for a certain condition
本文介绍了sql查询某个条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我有一张像这样的表:
Hi
I have a table like:
empId empSalary empDept
1 45000 IT
2 40000 IT
3 50000 SALES
4 60000 SALES
5 75000 IT
6 80000 IT
7 25000 OPS
8 30000 OPS
9 55000 MARKETING
10 60000 MARKETING
我必须回头查询如下:
I have to write a query as:
select empId where empSalary > avg(empSalary) for each empDept
请帮助。
Kindly help.
推荐答案
试试这个
try this
select empId from tbl t1 where empSalary >
(select AVG(empSalary) from tbl t2 m where t1.empDept =t2.empDept )
这篇关于sql查询某个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文