Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

MAX Rate and Max Hours

$
0
0

Hi All

Been working on my T-SQL skills using the AdventureWorks 2008 database.

I want to get the Employee with the highest rate as well as the highest SickLeaveHours

This is what I have so far, am I heading in the right direction?

with cte as (
select he.EmployeeID, he.SickLeaveHours, ep.Rate 
, ROW_NUMBER () over (order by ep.rate desc) rn
from HumanResources.Employee he
inner join HumanResources.EmployeePayHistory ep on he.EmployeeID = ep.EmployeeID
where he.SickLeaveHours = (select MAX (he.SickLeaveHours) from HumanResources.Employee he))
select * from cte where rn = 1


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>