CASE

From SQLZoo
Compatibility
CASE WHEN b1 THEN v1 END
EngineOKAlternative
ingresYes
mysqlYes
oracleYes
postgresYes
sqlserverYes

CASE

CASE allows you to return different values under different conditions.

If there no conditions match (and there is not ELSE) then NULL is returned.

 CASE WHEN condition1 THEN value1 
 WHEN condition2 THEN value2 
 ELSE def_value 
 END 
SELECTname,population
,CASEWHENpopulation<1000000
THEN'small'
WHENpopulation<10000000
THEN'medium'
ELSE'large'
END
FROMbbc

See also

Language: Project:Language policy English  • Deutsch  • 日本語
Kaleidoscope - get a kaleidoscope view using your phone/laptop camera
  • Served by: noddy at 2026年07月05日T11:00