如何用员工姓名编写员工最高工资的sql查询 [英] how to write sql query for max salary of employee with employee name
本文介绍了如何用员工姓名编写员工最高工资的sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的桌子上有员工姓名,部门,工资
i想获得最高工资在每个部门
任何人都可以帮助我
解决方案
尝试:
SELECT EmpName,Dept,Salary FROM
( SELECT *,ROW_NUMBER() OVER ( PARTITION BY 部门订单 按薪资 DESC ) AS rn
FROM mytable4)x
WHERE rn = 1
试试这个:
选择名称,dept,sal ary 来自 table1 t1
其中薪水=(
select max(薪水)来自 table1 t2 其中 t1.dept = t2 .dept
)
从tblname中选择姓名,工资,其中包括工资(选择MAX(工资)) tblname)大>
i have table with column employee name , dept, salary
i want to get max salary in each dept
can any one help me
解决方案
Try:
SELECT EmpName, Dept, Salary FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY Dept Order By Salary DESC) AS rn FROM mytable4) x WHERE rn = 1
Try this:
select name, dept, salary from table1 t1 where salary = ( select max(salary) from table1 t2 where t1.dept=t2.dept )
select name,salary from tblname where salary in (select MAX(salary) from tblname)
这篇关于如何用员工姓名编写员工最高工资的sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文