The CASE statement which resulted in error was like this:
SELECT
CASE WHEN StudentId = 0 THEN null END
I wanted to return NULL when StudentId = 0; else return the StudentId.
The above query did not work without the ELSE part. After adding the ELSE section like below the query executed without error:
SELECT
CASE WHEN StudentId = 0 THEN null ELSE StudentId END
No comments:
Post a Comment