私はこの要求を持っていますが、うまく動作しません。mysqlのsum amont
select date_format(date, "%Y-%m-%d") as month,
sum(value) as total
from :table_orders_sales_commission
where date_sub(now(), interval 12 month) <= date
group by month
結果は次のとおりです。
2017-04-02 4.6440
2017-04-03 2.6200
どのように1ヶ月(4.644 + 2.62)の合計を持っていますか?
日付とグループから月を抽出する必要がありますあなたはあなたが望むものを得るでしょう – Rams
月の書式を設定するときに昼の部分を削除するだけですf ield。現在、グループではその日も含まれています。 date_format(日付、 '%Y-%m')を月として表します。 – JuveLeo1906