Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

how to best use a case when statement (if at all).

$
0
0

This is a bit of a continuation ofhttps://community.spiceworks.com/topic/2149315-returning-a-null-value-when-query-returns-nothing.

Ok, so the code stands as seen below.

select isnull (m1, 0) as m1, select isnull (m2, 0) as m2, select isnull (m3ep, 0) as mnth3emp
from dbo.industryimport20172f
where area='000003' and indcode='21' and ownership='00' and suppress='0'
union all
select isnull (mnth1emp, 0) as mnth1emp, select isnull (mnth2emp, 0) as mnth2emp, select isnull (mnth3emp, 0) as mnth3emp
from dbo.industryimport20172f
where area='000003' and indcode='212' and ownership='50' and suppress='0'
union all

My question is if I can insert a case when statement for the suppress at the end of each section (after the snippet about ownership = 'X'). If suppress=1 then have it report it as NULL. If suppress='0' then produce the m1, m2, m3. Or do I need...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>