The CASE Function
You can use the CASE function to provide conditional values to an expression.
Caution
You cannot use the CASE function to provide conditional execution of statements as in other programming languages.
The result of a CASE function is always a scalar value. You can use CASE in two different ways:
Select a result depending on the possible values that a variable, column, or expression can have. This is called Simple CASE. CASE returns the value correspondent to the first value that is equal to the searched expression. Listing 11.16 contains three examples using the CASE function to provide a verbose output.
The CASE function evaluates in sequence several independent conditions. The CASE function returns the result correspondent ...
Get Microsoft® SQL Server™ 2000 Programming by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.