Example 1
Label order totals as low, medium, or high
Conditions are evaluated in order. Order 1 (30) hits the first branch, order 2 (75) hits the second, and order 3 (300) falls through to ELSE.
Source table data Rows loaded before the example query runs.
Setup
CREATE TABLE orders (id INT, total INT);
INSERT INTO
orders (id, total)
VALUES
(1, 30),
(2, 75),
(3, 300);Validated query Shared across supported engines.
SQL
SELECT
id,
total,
CASE
WHEN total < 50 THEN 'low'
WHEN total < 200 THEN 'medium'
ELSE 'high'
END AS size
FROM
orders
ORDER BY
id;Expected result Returned rows for the shared example.
| id | total | size |
|---|---|---|
| 1 | 30 | low |
| 2 | 75 | medium |
| 3 | 300 | high |
Output is identical across all engines.