0

我有以下(MySQL)表名为“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

如何计算和分组销售,按周计算?

还有1个问题请帮助我,如何自动显示下周的数据???

4

1 回答 1

3

使用YEARWEEK()

select sales, 
       yearweek(date) as week_date, 
       sum(total) as week_total
from sls_ord
group by sales, yearweek(date)

我假设您的意思是求和而不是计数。

于 2013-05-24T21:25:31.300 回答