Guest User

Untitled

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