1/* Return The First Non Null Value*/
2
3SELECT Column_Name, COALESCE (Col1, Col2, Col3,...) AS Alias_Name FROM Table_Name
4
5For Example
6/*
7ID First_Name Middle _Name Last_Name
81 Sam null null
92 null John null
103 null null smith
11*/
12SELECT ID, COALESCE (First_Name, Middle_Name, Last_Name) AS Name
13FROM tblCOSTOMER
14/*
15Output
16ID Name
171 Sam
182 John
193 smith
20*/
1Return the first non-null value in a list:
2
3SELECT COALESCE(NULL, NULL, NULL, 'W3Schools.com', NULL, 'Example.com');
4
5-- output: W3Schools.com