How to Use CASE WHEN in Oracle
Last updated August 25, 2026 · By the SaturnSQL team
CASE has a simple form comparing one expression to a list of values and a searched form evaluating conditions; it works anywhere an expression fits.
Simple CASE
SELECT employee_id,
CASE department_id
WHEN 10 THEN 'Admin'
WHEN 20 THEN 'Sales'
ELSE 'Other'
END AS department_name
FROM employees;Searched CASE
Searched CASE evaluates independent boolean conditions instead of comparing one expression against a list of values, so it can mix columns, ranges, and operators freely.
SELECT employee_id, salary,
CASE
WHEN salary >= 10000 THEN 'High'
WHEN salary >= 5000 THEN 'Mid'
ELSE 'Low'
END AS salary_band
FROM employees;CASE isn't limited to the SELECT list. ORDER BY CASE WHEN status = 'urgent' THEN 0 ELSE 1 END sorts urgent rows first without a separate sort column, and SUM(CASE WHEN region = 'EU' THEN amount ELSE 0 END) turns one aggregate query into several conditional totals without a self-join or extra GROUP BY.
Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free