Created
March 4, 2019 02:22
-
-
Save random82/a2dbc702f1dff517b077ede526a00e9e to your computer and use it in GitHub Desktop.
Get last job in a day
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;WITH cte_dailyJobs AS ( | |
SELECT | |
DataLoadJobId, | |
LoadTime, | |
RANK() OVER(PARTITION BY CONVERT(date, LoadTime) ORDER BY LoadTime DESC) AS Rank | |
FROM [dbo].[DataLoadJob] | |
) | |
SELECT * FROM cte_dailyJobs WHERE Rank = 1 | |
ORDER BY LoadTime DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment