[Solved] Current month and last month data in single row


You can use an aggregate function with a CASE expression similar to this:

select itemname,
  sum(case when month(date) = month(getdate()) -1 then amt else 0 end) LastMonthAmt,
  sum(case when month(date) = month(getdate()) then amt else 0 end) CurrentMonthAmt
from yourtable
group by itemname;

See SQL Fiddle with Demo

0

solved Current month and last month data in single row