Wednesday 28 August 2013

COALESCE function in PLSQL

The COALESCE function take n arguments and produce the first argument, which has the first not null value.
i.e.
Select * from test;
A                      B                      C
-------                 -------                 -------
10                                             30
                        21                     31
12                     22                     32
                                                33
i.e.
Select c, coalesce(a,b,0) result from test;
C                      result
-------                 -------
30                     10        
31                     21
32                     12
33                     0

No comments:

Post a Comment