What is the SQL case statement ? (or switch)

Data System Architecture


In sql, the case expression 1) is a conditional expression that is the equivalent to the more general switch expression (same function, just another word).


As for a switch statement, there is also two ways to write a case statement:

  • with values
  • with conditional expressions

Values based Case

CASE  Promotions."Promo Subcategory"
WHEN  'TV commercial'          then 'Commercial'
WHEN  'TV program sponsorship' then 'Sponsor'
ELSE  'Default'

Conditional Expression based Case

CASE WHEN "Sales Facts"."Amount Sold" > 600000  THEN 'Big'
     WHEN "Sales Facts"."Amount Sold" > 300000  THEN 'Middle'
     ELSE 'Small' END

Discover More
Obiee Case When Lookup
OBIEE - Case When Statement

This article is the case expression in OBIEE Logical SQL. This operator calculation have two type: the the In a CASE statement, AND has precedence over OR. If no ELSE expression is specified,...
Sqlite Banner
SQLite - Case statement

The case statement in sqlite The value base format with the weekday name from its number (o being sunday). The conditional based format Example where Saturday and Sunday are marked as weekend...
Sqlite Banner
SQLite - Date

The date data type in SQLite context does not exist. It is not an affinity. SQLite are capable of storing dates and times with the following data type (affinity) as: TEXT with ISO8601 strings (“YYYY-MM-DD...
Sqlite Banner
Sqlite - If Statement

Most SQL database does not use the if construct but the conditional case statement to express a condition. For example where Saturday and Sunday are marked as weekend and the other days as midweek
Card Puncher Data Processing
What is a Switch Statement in computer language?

A switch is a multi-way conditional branch that permits to control the flow There is basically two syntax: the where the possibilities are scalar values the where the possibilities are expressions...

Share this page:
Follow us:
Task Runner