Created
May 6, 2011 23:44
-
-
Save johngibb/960013 to your computer and use it in GitHub Desktop.
Max's Query
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 LatestComments as ( | |
select | |
c1.ClaimNumber | |
, commentClaimId = c2.ClaimNumber | |
, co.PV_Message | |
, co.PV_ComlogDate | |
, rn = row_number() over (partition by c1.ClaimNumber order by co.PV_ComlogDate desc) | |
from tbl_Accounts_Charges c1 | |
join tbl_Accounts_Charges c2 | |
on c2.AccountNumber = c1.AccountNumber | |
join tbl_MSI_Comlog_Backload2 co | |
on co.PV_ClaimNumber = c2.ClaimNumber | |
) c | |
) | |
select * | |
from LatestComments | |
where rn = 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment