Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT MAX([WEEK]) FROM MyTable WHERE [Year] = DATEPART(YYYY, GETDATE())
- CASE
- WHEN [WEEK] <= (SELECT MAX([WEEK]) FROM MyTable WHERE [Year] = DATEPART(YYYY, GETDATE())) THEN
- [YEAR]
- END YTD,
- CREATE TABLE [dbo].[MyTable](
- [Week] [tinyint] NULL,
- [Year] [date] NULL,
- ) ON [PRIMARY]
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement