Created
February 17, 2016 21:10
-
-
Save chasewoodford/fe3b0406765ea73fa7eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
-- When you need to find the submitted datetime of the second interaction submitted by each and every doc in our database | |
LEFT JOIN ( | |
SELECT * | |
FROM ( | |
SELECT | |
ROW_NUMBER() OVER(PARTITION BY [PhysicianID] ORDER BY [WhenSubmitted]) AS ROW, | |
[PhysicianID], | |
[WhenSubmitted] | |
FROM [dbo].[Recording] | |
) AS tmp | |
WHERE ROW = 2 | |
) AS tmp2 | |
ON tmp2.[PhysicianID]=dr.[UID] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment