Below is the code that I am using to sum up across 3 values of a field titled ownership. In the original data set, there are 3 values (mnth1emp, mnth2emp, mnth3emp) per ownership codes 10, 20, and 30. The code is yielding correct results but the result is in column fashion. The end report displays the data horizontally. Is there a simple way to pivot this result without changing the code fundamentally?
Text
select sum(mnth1emp) mnth1emp from ( select CASE WHEN suppress = 0 then isnull (mnth1emp, 0) ELSE '-1' END as mnth1emp from dbo.industryimport20172f where area='000510' and indcode='000000' and ownership='10' union all select CASE WHEN suppress = 0 then isnull (mnth1emp, 0) ELSE '-1' END as mnth1emp from dbo.industryimport20172f where area='000510' and indcode='000000' and ownership='20' union all select CASE WHEN suppress = 0 then...