DECLARE @TestVal int
SET @TestVal = 5
SELECT
CASE
WHEN @TestVal <=3 THEN 'Top 3'
ELSE 'Other'
END
I saw this sample code online, but I could not find an example where there was no expression, and it had more than one WHEN, so I wonder if this is normal in this case:
DECLARE @TestVal int
SET @TestVal = 5
SELECT
CASE
WHEN @TestVal <=3 THEN 'Top 3'
WHEN (select ...) = 1 THEN 'Other Value'
WHEN (select ...) = 2 THEN 'Other Value 2'
ELSE 'Other'
END
Or do I need to say CASE WHEN for each line?
source
share