Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- [Contra],
- [Schedule],
- SUM(CAST([UsedSM] AS float)) AS [UsedSM],
- SUM(CAST([TotalSU] AS int)) AS [TotalSU],
- SUM(CAST([UsedSU] AS float)) AS [UsedSU],
- MatchExpireDate = Case When FIRST_VALUE(Schedule) OVER (PARTITION BY [Contra]
- ORDER BY [Schedule] ASC
- ROWS UNBOUNDED PRECEDING
- ) = [Schedule] Then 'Match'
- Else 'Not' End
- FROM [dbMartxxx].[dbo].[tblPDPcontracts]
- where MatchExpireDate = 'Match'
- GROUP BY [Contra],
- [Schedule]
- ORDER BY [Contra] DESC;
- GO
Add Comment
Please, Sign In to add comment