Coalesce(Add together different elements) used as a Case statement in SQl server.If the value in one of the columns is not available then use the value of the second column and if that is also not available, then use the third column. If none of the columns have the value, then null is returned for that value.
I’ve a table having structure as depicted below:
I will apply on Coalesce function on Category table to fetch information of three columns in a single column alias.it ignores null values of each columns.
I have created a query to retrieve desired information.kindly see an image depicted below:
if you notice in above shown image we have combined three columns(having null values also) together and get as single column Category.
Note: it doesn’t fit in that condition, if you have columns having values (other than Null) in a table and want to put into Coalesce function .
I’ve changed a structure little bit and added one more column Technology into Category table.Kindly see a Category table structure in an image shown below.
It returns value of first non-null column.I’ve changed a query as well and added “Technology” column Coalesce function.
Kindly refer image shown below.
Its very simple to learn and may be utilized in future.
- Smart Working With Custom Value Providers in ASP.Net MVC
- Invoke Action With Model Binders in MVC
- Extension Helpers Method in MVC
- Custom Button With TagBuilder Using MVC Razor Engine
- Precompiled Razor View Using RazorGenerator MVC and PreCompiledViewEngine in MVC 4
- RETURN MULTIPLE MODELS IN SINGLE VIEW IN MVC3
- CALL CONTROLLER ACTION METHOD FROM JQUERY USING AJAX
- EXECUTION ORDER OF FILTERS IN MVC 4 WITH PRACTICES: IMPORTANT FAQ
- MEANING OF SCAFFOLDING IN MVC
- REMOVE AMBIGUTY OF CONTROLLER NAMES IN MVC APPLICATION
- CUSTOM BUTTON WITH TAGBUILDER TECHNIQUE USING MVC RAZOR ENGINE
- CONVERSION HELPERS IN MVC RAZOR: VALIDATING POSTED DATA
- LOOP THROUGH MODEL ITEMS IN ASP.NET MVC
Thanks
Sachin Kalia
0 comments :
Post a Comment