How to apply CASE in Query

If you want to apply some checks in query then best option is to use Cases.
example of case is below:

Select Building.ID,Building.Name,

case when Building.Status='Completed' or Building.Status='Renovate' then
Building.Size
else

end as 'BuildingSize'


It will check for building status and return Building size if building status is completed or renovate and return 0 when the above condition is not satisfied.

Comments

Popular posts from this blog

TSQL To Get All the Names of tables and Databases whose data have changed in last 24 Hours

To Get All the Names of tables and Databases their data have changed in last 24 Hours And Backup those databases

Apply paging in procedure