Is there an ANSI SQL equivalent to Oracle's DECODE function?
Oracle's decode function is the IF-THEN-ELSE construct in SQL.
A CASE expression is the ANSI SQL method, of which there are 2 varieties, "simple" and "searched":
1) Simple CASE expression:
CASE col WHEN 1 THEN 'One'
WHEN 2 THEN 'Two'
ELSE 'More'
END
2) Searched CASE expression:
CASE WHEN col < 0 THEN 'Negative'
WHEN col = 0 THEN 'Zero'
ELSE 'Positive'
END