Quantcast
Channel: Recent Edits
Viewing all articles
Browse latest Browse all 12198

Getting the Current Salary Rate from EmployeePayHistory

$
0
0
The EmployeePayHistory table includes past salary rates if any. It requires a subquery (or CTE) to obtain the current salary rate only. For example, using nested CTE-s:WITH CTE AS (SELECT EmpID=BusinessEntityID, RN=ROW_NUMBER() OVER (PARTITION BY BusinessEntityID ORDER BY RateChangeDate DESC), RateFROM HumanResources.EmployeePayHistory),EmpPayRate AS (SELECT EmpID, Rate FROM CTE WHERE RN = 1)SELECT * FROM EmpPayRate ORDER BY EmpID;-- (290 row(s) affected)/*EmpID Rate1 125.502 63.46153 43.26924

Viewing all articles
Browse latest Browse all 12198

Trending Articles