I have a mysql table with sales information: Seller, product, sales date.
How do I write a query to generate a table that shows total products shown by each seller, per month, and in total?
This is the query I use to create a table with SellerName and total sales in July:
select SellerName, count(*) as july
from onlineDATA
where ReportMonth = 201207
GROUP BY SellerName
ORDER BY july DESC
LIMIT 0,30
How do I modify this to get additional sales totals for each month?
I am looking for output like this:
SellerName | Jun | Jul | Aug | YTD
John Doe | 30 | 25 | 30 | 85
Bonus question - how would I code this in PHP when the number of months would be a user input - anywhere from 1 to 12?
Thanks