Description:
Here i will explain how to use ternary operator in sql server. Ternary operator works like IF condition. It check the condition, if condition is true then return result1 else return result2 as you defined.
Syntax:
Here i will explain how to use ternary operator in sql server. Ternary operator works like IF condition. It check the condition, if condition is true then return result1 else return result2 as you defined.
Syntax:
SELECT (CASE [ColumnName]
WHEN [Value]
THEN [Result1]
THEN [Result1]
ELSE [Result2]
END)
FROM [TableName]
Example:
SELECT (CASE Department
WHEN 'software'
THEN 'winod'
THEN 'winod'
ELSE 'jaydeep'
END)
FROM Department
No comments:
Post a Comment