The searched approach uses conditional operators to arrive at true or false for which branch to take as suggested here. The simple approach is more like a case/switch statement. This has this example which seems to use the AdventureWorks database which is some dummy database that is used in dummy scenarios like the Northwind database.
USE AdventureWorks2012;
GO
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
ORDER BY ProductNumber;
GO
You may have an OR or an AND in a searched case statement like so:
WHEN Yin > 13 or Yang < 42 THEN 'Meh'
No comments:
Post a Comment