Dear All!
I want to get my columns value into rows . i am taking sum of qty of each month . like this
select sum(Case when month(invoicedate) = 1 then qty else 0 end) as janQty,
sum(Case when month(invoicedate) = 1 then qty else 0 end) as febQty,
sum(Case when month(invoicedate) = 1 then qty else 0 end) as marQty,
.
.
.
from Invoices
above query is returning result like this
janQty---------febQty---------marQty-------------
--156-----------678-------------345------
and my required format is
janqQty------156
febqQty------678
marqQty------345
.
.
.
i can use union all like this this
select 'jan' as month, sum(case when month(invoicedate) = 1 then qty else 0 end ) as Qty
from invoice
union all
select 'feb' as month, sum(case when month(invoicedate) = 1 then qty else 0 end ) as Qty
from invoice
union all
select 'mar' as month, sum(case when month(invoicedate) = 1 then qty else 0 end ) as Qty
from invoice
.
.
.
.
But i dont want to use this method, Please guide me how i can do this in a simple way.
Regards