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
0
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.
example of case is below:
Select Building.ID,Building.Name,
case when Building.Status='Completed' or Building.Status='Renovate' then
Building.Size
else
0
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
Post a Comment