Reputation: 33
I have the following (MySQL
) table called "sls_ord
":
Sales Total Date
joko susilo Rp. 12.000.000; 24-May-2013
wenini Rp. 13.000.000; 25-May-2013
Supardjo Rp. 13.300.000; 20-May-2013
wenini Rp. 20.300.000; 6-May-2013
joko susilo Rp. 23.300.000; 8-May-2013
joko susilo Rp. 24.000.000; 1-May-2013
How to count and group sales
, total by week
?
1 more question please help me,, how to display the data in the next week automatically ???
Upvotes: 1
Views: 211
Reputation: 1523
For the 1st part of your question:
SELECT COUNT(*), WEEK(Date) FROM sls_ord GROUP BY WEEK(Date);
I am assuming that the Date
field if of Datetime
type
Also, as rightly said by @Raphael, you can add YEAR(Date)
and MONTH(Date)
in the GROUP BY
and in the column list
Upvotes: 1