Lesson 11. Displaying Data Based On Conditions (Case Statement)
Sometimes the data you want to output will depend on data in other columns. You can do that with a CASE statement in your SELECT clause.
The CASE statement comes in two flavors, but my personal preference is to always use what is called the searched CASE expression.
SQL Server evaluates the CASE statement in a lazy way. It does not check all conditions. It starts from the first condition and works its way down until a condition evaluates to true.
CASE Syntax
Examples
Two Examples Of CASE Statements
PreviousLesson 10. Creating New Columns From Existing Data (Calculated Fields)NextLesson 12. Aggregate Functions
Last updated