Is there an ANSI SQL equivalent to Oracle\'s DECODE function?
Oracle\'s decode function is the IF-THEN-ELSE construct in SQL.
Please note that Oracle DECODE treats null as equal to null, while CASE(and any other comparisons) don't.
Example: Decode(a,b,1,0) will return 1 if both a and b are nulls.
Just run these 2 statements to see the difference.
select case null when null then 'Y' else 'N' end dd from dual;
select decode(null, null, 'Y', 'N') dd from dual;