Dear All,
I have a SQL question not able to get exact record.
How to get Monthly Highest Sales Person in given record.
Please tell me where I am wrong.
Employee Table:
Sales Table:
Expected Result:
Tried Query:
With Temp AS(
Select e.empID,SUm(s.Sale) as Sale,s.monthname
From tblEMp e inner join tblSales s on e.empID=s.empID
Group by s.monthname,e.empiD)
Select Distinct(Sale),empID,monthName from Temp Where Sale in (Select Max(Sale) from Temp Group by monthName)
Group by monthName,empID,sale
order by monthname
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Amit MohantyRank #112 · 20K reputationPosted Sep 12, 2019, 10:47 PM EDT
Abdul Amin KhanRank #2,247 · 627 reputationPosted Sep 16, 2019, 8:25 PM EDT