Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
SQL

CASE Statement in SQL

Write conditional logic in queries with CASE.

CASE Statement in SQL — a practical guide to SQL CASE statement with clear examples you can reuse in real projects.

SQL Tutorial Series (44/100). Prefer one article? Read the complete SQL tutorial.

Short description

CASE is the standard way to map values without multiple queries.

Case

SELECT id,
  CASE status
    WHEN 'paid' THEN 'Completed'
    WHEN 'pending' THEN 'Awaiting payment'
    ELSE 'Other'
  END AS status_label
FROM orders;

Leave a reply

Your email address will not be published. Required fields are marked *