Coalesce Function
Displays the first nonnull expression among its arguments
-- returns Iam Not a Null
Select Coalesce (Null, Null, 'Iam Not a Null', Null) as NotNull
This function will be used to skip the NULL columns and get the ones that have value. This function can be maximum utilised in situations where you need to get one value from a group of columns that could contain null.
For example, Let us assume that you have a contact table with office_phno, mobile_nos, home_phnos in it and you need to send them greetings. You can use Coalesce Function to get the non null number according to priority
Select Coalesce (Office_phno, mobile_nos, home_phnos, 'No Ph No Available) as ContactNo
Saturday, April 28, 2007
Coalesce Function
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment