[PHP] Totaling sales by month

2004-09-10 Thread Brian Dunning
I have a MySQL db with a datetime field containing the date and time of the sale. I want to query for a simple report that shows total sales by month. I thought this would be quick easy but it's NOT! I can't figure out how to query for it. If this question would be better posed to a SQL

Re: [PHP] Totaling sales by month

2004-09-10 Thread Brian Dunning
Thanks Pablo - but it's more complicated than that. I'm trying to return totals for all calendar months, not all records within the past month. I'll word my question better and post it to one of your suggested lists. :) On Sep 10, 2004, at 4:27 PM, Pablo Gosse wrote: Brian Dunning wrote: I

Re: [PHP] Totaling sales by month

2004-09-10 Thread Andrew Kreps
This one worked for me, on MySQL 3.23.xx. I hope it's closer to what you need. select sum(ordersubtotal), date_format(orderdate, '%Y-%m') as odate from orders group by odate On Fri, 10 Sep 2004 15:01:34 -0700, Brian Dunning [EMAIL PROTECTED] wrote: I have a MySQL db with a datetime field

Re: [PHP] Totaling sales by month

2004-09-10 Thread Brian Dunning
Amazing - that did it, first try! THANKS. I knew it had to be simple. SQL rocks. - Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Totaling sales by month

2004-09-10 Thread John Holmes
Andrew Kreps wrote: I have a MySQL db with a datetime field containing the date and time of the sale. I want to query for a simple report that shows total sales by month. This one worked for me, on MySQL 3.23.xx. I hope it's closer to what you need. select sum(ordersubtotal),