本文介绍了使用group by子句连接表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在sql中编写了以下查询行
I have written following line of query in sql
select did Deptid,MAX(salary)'Highest Salary' from Empmaster e,Deptmaster d
where e.did=d.deptid
group by did
这给我输出为
110 100000.00
120 65000.00
130 50000.00
140 45000.00
但如果我想显示具有相同查询的员工姓名该怎么办。
我需要在abouve查询中额外编写。
请帮我解决这个问题
提前谢谢
this gives me output as
110100000.00
12065000.00
13050000.00
14045000.00
but what if i want to display a name of employee with the same query .
what i need to write extra in the abouve query.
Please help me to solve this query
Thank in advance
推荐答案
select Deptid,Employeename,salary from
(
select row_number() over(order by e.did,salary desc) as srno,
did Deptid,e.EmployeeName,salary
from Empmaster e
JOIN Deptmaster d on e.did=d.deptid
group by did,e.EmployeeName
) as temp
where SrNo=1
快乐编码!
:)
Happy Coding!
:)
select did Deptid,e.EmployeeName,MAX(salary)'Highest Salary'
from Empmaster e
JOIN Deptmaster d on e.did=d.deptid
group by did,e.EmployeeName
投票如果有帮助你。
:)
vote if it helps u.
:)
这篇关于使用group by子句连接表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!