Trying to run the SQL using a case
expression but seems there is an syntax error
SELECT
MAX(date) AS maxdate,
MIN(date) AS mindate,
id
WHERE
(iSkid = 1)
CASE
WHEN PageList = 0
THEN
AND (startdate <= DateAdd(Day, DateDiff(Day, 0, GetDate()), 0))
AND (enddate >= DateAdd(Day, DateDiff(Day, 0, GetDate()), 0))
END
GROUP BY
id, maxdate, mindate
Errors I get:
Msg 156, Level 15, State 1, Line 95
Incorrect syntax near the keyword 'CASE'.
tried this way too
select max(date) as maxdate,min(date) as mindate, id
CASE WHEN
PageList = 0
THEN
WHERE (iSkid = 1) AND (startdate <= DateAdd(Day, DateDiff(Day, 0, GetDate()), 0))
AND (enddate >= DateAdd(Day, DateDiff(Day, 0, GetDate()), 0))
ELSE
WHERE (iSkid = 1)
END
GROUP BY
id,maxdate,mindate
Msg 156, Level 15, State 1, Line 95
Incorrect syntax near the keyword 'CASE'.
but something is messed up, and not sure what. any clue?