Skip to content

Instantly share code, notes, and snippets.

@johngibb
Created May 6, 2011 23:44
Show Gist options
  • Save johngibb/960013 to your computer and use it in GitHub Desktop.
Save johngibb/960013 to your computer and use it in GitHub Desktop.
Max's Query
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