CASE Expressions and DECODE
ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated
CASE is the ANSI conditional expression usable in SQL and PL/SQL; DECODE is Oracle's older equality-only equivalent.
How it works
A CASE expression returns a value: simple CASE x WHEN 1 THEN ... , or searched CASE WHEN x > 0 THEN ... ELSE ... END. It is distinct from the CASE statement (which ends with END CASE). DECODE(expr, s1, r1, s2, r2, default) does the same by equality only, treats two NULLs as equal (CASE does not), and is SQL-only. Prefer CASE for readability and portability; reach for DECODE mainly in legacy code.
How it works
SELECT last_name,
CASE
WHEN salary >= 15000 THEN 'A'
WHEN salary >= 8000 THEN 'B'
ELSE 'C'
END AS band,
DECODE(department_id, 10, 'Admin', 20, 'Mktg', 'Other') AS dept_label
FROM employees;Related questions
GroundingGenerated
Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.