WBAR
WBAR

Reputation: 4984

Multiple NVL() alternative - first not null parameter

Currently I have something like that:

NVL(COL1, NVL(COL2, NVL(COL3, NVL(COL4, NVL(COL5, COL6)))))

Is in Oracle 11gR2 any function that returns first NOT NULL parameter ?

Upvotes: 1

Views: 1947

Answers (2)

Mudassir Hasan
Mudassir Hasan

Reputation: 28771

Use COALESCE() function , it returns first non null value in expression list.

SELECT COALESCE(col1,col2,col3,col4,col5,col6)
FrOM tableName

Upvotes: 3

mvp
mvp

Reputation: 116317

Perhaps you are looking for COALESCE()?

Note that COALESCE() is supported on almost all khown databases: Oracle, PostgreSQL, MySQL, MSSQL, SQLite.

Upvotes: 2

Related Questions