Here are the CASE
statement examples from the PostgreSQL docs (Postgres follows the SQL standard here):
SELECT a,
CASE WHEN a=1 THEN 'one'
WHEN a=2 THEN 'two'
ELSE 'other'
END
FROM test;
or
SELECT a,
CASE a WHEN 1 THEN 'one'
WHEN 2 THEN 'two'
ELSE 'other'
END
FROM test;
Obviously the second form is cleaner when you are just checking one field against a list of possible values. The first form allows more complicated expressions.