Need SQL help

Sorry I’m a sql novice and need some help. When I run the query below it returns a separate row for each custid,month. I would like the result set to be rednered as follows:

select custid, to_char (date,‘mm/yyyy’), sum (slsqty), sum (slsdol) from dailysales where orderstate in (2,3) and date between ‘2011-01-01’ and ‘2011-07-31’
group by 1,2

Something like this should do it:

SELECT custid, sum (slsqty), sum (slsdol) FROM dailysales WHERE orderstate IN(2,3) AND date BETWEEN '2011-01-01' AND '2011-07-31' GROUP BY custid

immerse, where are the monthly columns? you’ve got only two SUM columns overall, but there should be two columns for january, two columns for february, etc.

Eep, you’re right! I guess I brushed over the exact desired column layout. Right. Back to the drawing board… (i.e. I need some time to work this one out :wink: )

justtrading, ignore my earlier post, it’s wrong…

Been trying stuff out, but TBH I have no idea how to transpose data in a MySQL result set without using PHP for the presentation bits, even though I’ve read some interesting stuff about group_concats, pivot tables and other zany stuff. Rudy, if you’d be so kind?

using php for the presentation bits is a great idea and my first recommendation