AI engineering glossary · SQL databases

What is CASE expression?

CASE expression: SQL's way of writing if-then-else inside a query. It checks conditions in order and returns the value of the first true branch, or an ELSE value. It can appear in SELECT, WHERE, ORDER BY and inside aggregates.

Level: beginnerTopic: SQL databases

CASE expression: an example

CASE WHEN amount >= 1000 THEN 'high' ELSE 'low' END labels each order as high or low value.

Related terms

More SQL databases terms

Where you learn it

CASE expression is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.