目的の出力に応じて、次の解決策のいずれかが機能するはずです。私はおそらく2番目の解決策にもっと傾くでしょうが、それはすべてあなたが見たいものに依存します:
select
s2.month as 'C-MONTH',
s1.month as 'P-MONTH',
s2.amt as 'C-AMT',
s1.amt as 'P-AMT'
from
(
select
datepart(m, saledate) as month,
sum(SaleAmt) as amt
from
Sales
group by
datepart(m, saledate)
) s1,
(
select
datepart(m, saledate) as month,
sum(SaleAmt) as amt
from
Sales
group by
datepart(m, saledate)
) s2
where
s2.month = s1.month + 1
デモ: http://sqlfiddle.com/#!3/66ad9/1
select
s2.month as 'C-MONTH',
s1.month as 'P-MONTH',
s2.amt as 'C-AMT',
s1.amt as 'P-AMT'
from
(
select
datepart(m, saledate) as month,
sum(SaleAmt) as amt
from
Sales
group by
datepart(m, saledate)
) s1
right outer join
(
select
datepart(m, saledate) as month,
sum(SaleAmt) as amt
from
Sales
group by
datepart(m, saledate)
) s2
on
s2.month = s1.month + 1
デモ: http://sqlfiddle.com/#!3/7a670/1