CHOOSE
conditional or n-ary selection
What changes
- Input
- a condition or index and value list
- Output or change
- one of the inputs
- Return type
- Returns the data type with the highest precedence from the set of types passed to the function. For more information, see Data type precedence.
Syntax at a glance
CHOOSE ( index , val_1 , val_2 [ , val_n ] )
Work example
Map a small one-based index to a label in a query result.
Check index zero, out-of-range values, and null before using the returned label.
Check your work CHOOSE returns null when the index does not select an item.
Practice SQL
Open in SQL FlowSELECT CHOOSE(2, 'draft', 'ready', 'sent') AS status_name;
Open Microsoft Learn for full syntax, permissions, and details for your version.