I have this select as follows:
SELECT SUBSTRING(Col1, 1, 3) AS 'Series',
b.Col2,
CAST(c.Price * c.Qty AS MONEY) AS Total
FROM tableName a
inner join ....
...
WHERE DATE BETWEEN '1/1/2012' AND '1/31/2012'
AND B IN ( 'C50', 'C51', 'C52', 'C53', 'C54' )
GROUP BY Col1,
b.Col2,
c.Price,
c.Qty
Which returns this result set:
Series Col2 Total
---------- ---------- ----------
105 C50 5.00
105 C50 15.00
105 C53 20.00
105 C53 20.00
105 C53 20.00
And this is how I would like it to work:
Series C50 C53
---------- ---------- ----------
105 20.00 60.00
Not sure how to do the inner selects to get that result. Any ideas?
Please try the following codes. You have to use PIVOT query.