Simple CASE Statement

SELECT 
	[ProductNumber], 
	[Category] =
		CASE [ProductLine]
			WHEN 'R' THEN 'Road'
			WHEN 'M' THEN 'Mountain'
			WHEN 'T' THEN 'Touring'
			WHEN 'S' THEN 'Other sale items'
			ELSE 'Not for sale'
		END,
	[Name]
FROM [Production].[Product];

Searched CASE Statement

SELECT
	[ProductNumber],
	[PriceRange] = 
    CASE 
        WHEN [ListPrice] =  0 THEN 'Mfg item - not for resale'
        WHEN [ListPrice] < 50 THEN 'Under $50'
        WHEN [ListPrice] >= 50 AND [ListPrice] < 250 THEN 'Under $250'
        WHEN [ListPrice] >= 250 AND [ListPrice] < 1000 THEN 'Under $1000'
        ELSE 'Over $1000'
    END
FROM [Production].[Product];

CASE in ORDER BY

SELECT 
	SalariedFlag, 
	BusinessEntityID
FROM HumanResources.Employee
ORDER BY 
	CASE [SalariedFlag]
		WHEN 1 THEN [BusinessEntityId]
		END DESC,
	CASE 
		WHEN [SalariedFlag] = 0 
			THEN [BusinessEntityId]
		END ASC;

Dynamic ORDER BY with CASE

DECLARE @OrderBy VARCHAR(10) = 'FirstName'
DECLARE @OrderByDirection VARCHAR(4) = 'DESC'

SELECT FirstName, LastName
FROM Person.Person
ORDER BY
	CASE WHEN @OrderBy = 'FirstName' AND @OrderByDirection = 'ASC' THEN FirstName END,
	CASE WHEN @OrderBy = 'FirstName' AND @OrderByDirection = 'DESC' THEN FirstName END DESC,
	CASE WHEN @OrderBy = 'LastName' AND @OrderByDirection = 'ASC' THEN FirstName END,
	CASE WHEN @OrderBy = 'LastName' AND @OrderByDirection = 'DESC' THEN FirstName END DESC

CASE in an UPDATE Statement

UPDATE HumanResources.Employee
SET [VacationHours] = 
    (CASE
			WHEN ((VacationHours - 10.00) < 0) THEN VacationHours + 40
			ELSE VacationHours + 20.00
		END)
WHERE SalariedFlag = 0;

CASE in WHERE Clause

SELECT *
FROM HumanResources.Employee
WHERE [JobTitle] = 
	CASE 
		WHEN LEN([JobTitle]) < 10 THEN 'Chief Executive Officer'
		ELSE [JobTitle]
	END

CASE in a HAVING Clause

SELECT 
	[E].[JobTitle],
	[MaximumRate] = MAX([PH].[Rate])
FROM [HumanResources].[Employee] AS [E]
INNER JOIN [HumanResources].[EmployeePayHistory] AS [PH]
	ON [E].BusinessEntityID = [PH].BusinessEntityID
GROUP BY [JobTitle]
HAVING
-- If men, their rate must be above 40.00
MAX(CASE [E].[Gender] WHEN 'M' THEN [PH].[Rate] ELSE NULL END) > 40.00
OR
-- If female, their rate must be above 42.00
MAX(CASE [E].[Gender] WHEN 'F' THEN [PH].[Rate] ELSE NULL END) > 42.00
ORDER BY [MaximumRate] DESC;

IIF for Binary Decisions

SELECT IIF (-1 < 1, 1, 0);