Guest User

Untitled

a guest
Jul 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. DECLARE @AsofDATE AS DATE
  2. DECLARE @AsofDateINT AS Int
  3. SET @AsofDATE ='1/1/2018'
  4. SET @AsofDateINT = 20180101
  5.  
  6. SELECT count(S.ClaimNum) Count_of_Claims , sum(ReserveIndemnityAmount) as RD_REserve ,@AsofDATE as AsofDate -- INTO #tempRD
  7. FROM ( SELECT f.* ,
  8. ROW_NUMBER() OVER ( PARTITION BY ClaimNum ORDER BY f.ModifiedDate DESC ) AS Row_order_desc
  9. FROM [dbo].[Snapshot] f
  10. WHERE CAST(f.ModifiedDate AS DATE) <= @AsofDATE
  11. ) S
  12. left outer join (SELECT ClaimKey, SUM( t.LossRsvAmt) AS ReserveIndemnityAmount FROM
  13. Stg.Claim_Transaction t WHERE TransactionDate <@AsofDateINT group by ClaimKey) T
  14.  
  15. on t.ClaimKey = s.ClaimID
  16. WHERE S.Row_order_desc = 1
  17. AND S.DerivedClaimStatus NOT IN ( 'Closed', 'Cancelled', 'Abandoned', 'Record only','Opened in error' )
  18. and s.specialty = 'RD'
  19.  
  20. Count_of_Claims RD_REserve AsofDate
  21. 15317 112192.15 2018-01-01
  22.  
  23. Count_of_Claims RD_REserve AsofDate
  24. 15317 112192.15 2017-01-12
  25. 15567 111592.15 2017-01-11
  26. 15356 15492.15 2017-01-10
Add Comment
Please, Sign In to add comment