oracle equivalent of mysql ifnull (no case, no if)

倖福魔咒の 提交于 2019-12-25 16:24:31

问题


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)


回答1:


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




回答2:


just found out:

SELECT nvl(columna, columnb) FROM mytable

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



来源:https://stackoverflow.com/questions/31409990/oracle-equivalent-of-mysql-ifnull-no-case-no-if

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!