Skip to content
Advertisement

Decode equivalent in postgres

There is no equivalent to the Oracle‘s DECODE()'Function InPostgres`. Is there anyone who wrote decode as a Function?

Advertisement

Answer

There is an equivalent. It’s called a CASE statement.

There are two forms of CASE:

Simple CASE:

Searched CASE:

CASE statements are easier to read; I prefer these over decode() in Oracle.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement