if else tsql code example
Example 1: else if sql server
IF (Expression 1)
BEGIN
Statement 1;
END
ELSE IF (Expression 2)
BEGIN
Statement 2;
END
..........
ELSE
BEGIN
Default Statement;
END
Example 2: how to write if case in select query in select statement
SELECT player_name,
CASE WHEN year = 'FR' AND position = 'WR' THEN 'frosh_wr'
ELSE NULL END AS sample_case_statement
FROM benn.college_football_players