How to use or in when section of case statement?
DECLARE @TestVal INT
SET @TestVal = 1
SELECT
CASE @TestVal
WHEN 1 THEN 'First'--- this line
WHEN 2 THEN 'First'--- and this line
WHEN 3 THEN 'Third'
ELSE 'Other'
END
instead of using two above lines I want to use something like this:
when 1 or 2 then 'First'
You can do this:
Here is the official documentation.