Guest User

Untitled

a guest
May 24th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. SELECT
  2. [Contra], [Schedule],
  3. SUM(CAST([UsedSM] AS float)) AS [UsedSM], SUM(CAST([TotalSU] AS int)) AS [TotalSU],
  4. SUM(CAST([UsedSU] AS float)) AS [UsedSU],
  5. MatchExpireDate = Case When FIRST_VALUE(Schedule) OVER (PARTITION BY [Contra]
  6. ORDER BY [Schedule] ASC
  7. ROWS UNBOUNDED PRECEDING
  8. ) = [Schedule] Then 'Match'
  9. Else 'Not' End
  10.  
  11. FROM [dbMartxxx].[dbo].[tblPDPcontracts] where MatchExpireDate = 'Match'
  12. GROUP BY [Contra], [Schedule]
  13. ORDER BY [Contra] DESC;
  14. GO
Add Comment
Please, Sign In to add comment