SQL Flow Field Guide

CASE

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

simple or searched conditional; first TRUE branch wins, else ELSE or NULL

What changes

Input
input expression and WHEN conditions
Output or change
one value per row
Return type
Returns the highest precedence type from the set of types in result_expressions and the optional else_result_expression. For more information, see Data type precedence. Return values Simple CASE expre

Syntax at a glance

CASE input_expression WHEN when_expression THEN result_expression [ ...n ] [ ELSE else_result_expression ] END

Work example

A displayed label depends on the first matching business condition.

Run the sample and add a boundary value. Order WHEN clauses from the most specific condition to the broadest.

Check your work CASE. Each input receives one label and the ELSE branch covers every unmatched value.

Practice SQL

Open in SQL Flow
SELECT CASE WHEN Score >= 50 THEN N'pass' ELSE N'review' END AS Result
FROM (VALUES (82), (41)) AS Scores(Score);

Open Microsoft Learn for full syntax, permissions, and details for your version.