Re: Totaling sales by month
| From: | John Holmes | Date: | Sat, 11 Sep 2004 04:05:40 +0000 |
| Subject: | Re: Totaling sales by month | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196387@lists.php.net to get a copy of this message | ||
Andrew Kreps wrote:
Also, SELECT SUM(ordersubtotal), YEAR(orderdate), MONTH(orderdate) FROM orders GROUP BY YEAR(orderdate), MONTH(orderdate) If you wanted the date parts in separate columns or wanted to limit to specific months. If you ever want to group by week, YEARWEEK() will come in handy, btw. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.comI 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), date_format(orderdate, '%Y-%m') as odate from orders group by odate