Home Forums SQL Server 2012 SQL Server 2012 - T-SQL Rewrite the statement RE: Rewrite the statement
Ken McKelvey
SSCoach
Points: 18766
More actions
February 9, 2016 at 5:18 am
#1857340
IF (@date IS NULL)
SET @day = (SELECT MAX(day1) FROM table1 WHERE date1 = (SELECT MAX(date1) FROM table1));
ELSE
SET @day = (SELECT MAX(day1) FROM table1 WHERE date1 = @date);