1

Eg : Table

COL1 COL2 COL3

ADAM NULL AAA

NULL EVE BBB

NULL NULL CCC

How to select first NOT NULL value? Please suggest. Thanks!!!

  • 2
    Which server? What exactly do you want as output? First non-null value per row or per column? Please give an example output. – Werner Henze Jan 14 '15 at 16:21
  • 2
    Quality is too poor to merit migration to [so]. Remember: please don't migrate crap. – bwDraco Jan 14 '15 at 18:21

1 Answers1

2

If you want the first value that is not NULL, you can use COALESCE:

select coalesce(col1, col2, col3) from table

It will still give you NULL if col1 and col2 and col3 are NULL.

Werner Henze
  • 4,887
  • 3
  • 19
  • 33