Skip to main content

SQLSERVER Functions- Coalesce()

SQL Server  built-in functions

Coalesce()

It is A function Is Very Much Useful at Run time When We Have Multi Value Attribute in a Table.
If U Consider below facts placed in a employee table With Id, Name, ph_no, Alt_no, Office no.

id
Name
Ph_ no
Alt_ no
Office no
101
Albert
999999
456453
321333
102
khan
null
null
123455
103
victor
112121
null
null
104
lovely
null
null
1897321

Above Employee table may have single value are three values if it have single value then it fill null  values with remaining attributes
When We Retrieve The Number from employee table That Number Should Not be Null value To get not null value from employee table We Use Coalesce() Function It Returns First Encountered Not Null Value  from employee table

select id , name ,coalesce(Ph_no,Alt_no,Office_no) as contact number from employee
 it returns
id
Name
Contact number
101
Albert
999999
102
khan
123455
103
victor
112121
104
lovely
1897321


Thank you

Comments

Popular posts from this blog

Fundamentals of Design Patterns

Fundamentals of Design Patterns   hi developers and programmers  in this post i am going to share Videos where i learned fundamentals of design patterns   it is great visual you can enjoy this  have a nice day

FAQS on DOTNET

Hello to every one who are fallowing my blog, today i attend one call from one Technical Recruiter (name is not required i think ) he asked some couple of question...ok i answered ....mean while  he asked one question (in my life never i feel it is relevant  for developer) who will use oops development environment? ha.. ha.. expect answer and update  to me   So far we received many request for FAQs on CSHARP, ASP.NET AND SQLSERVER for fresher who are in finishing schools. We are actively working with these Technologies  to bring   KEY   Resources for   TECHIES.                                   you are interested in helping others  bring  TECHKEYS   to your Friends through Social Media, please Leave the Comment to us to improve our work and subscribe  for more information .   Q 1) levels of nesting in a subq...