0

I am looking for a quick way to do

SELECT IFNULL(columna, columnb) FROM mytable

(I have dozens of columns and don't want to write a case for each of them)

NotGaeL
  • 8,344
  • 5
  • 40
  • 70

2 Answers2

3

You can also use the standard COALESCE keyword, which allows you to pass it multiple parameters:

SELECT COALESCE(columna, columnb, ..., columnz) FROM mytable

COALESCE keyword documentation

sstan
  • 35,425
  • 6
  • 48
  • 66
2

just found out:

SELECT nvl(columna, columnb) FROM mytable

http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions105.htm

NotGaeL
  • 8,344
  • 5
  • 40
  • 70