私はMySQLデータベースからいくつかの統計を取得する必要があります。注文サイズの範囲で注文量を取得する必要があります。その後、WEEK、テーブルcreated_at in orders価格帯での注文数と週番号によるグループ
これは意味があると思います。
ここで私が思いついたことはありますが、高度なMySQLでの経験はほとんどありません。細かい範囲と注文を出力
SELECT
x.Kurv, COALESCE(ordre, 0) AS ordre
FROM (
SELECT "0 - 100" AS Kurv
UNION SELECT "100 - 200"
UNION SELECT "200 - 300"
UNION SELECT "300 - 400"
UNION SELECT "400 - 500"
UNION SELECT "500 - 600"
UNION SELECT "over 600") x
LEFT JOIN
(SELECT
CASE when base_total_ex_tax >= 0 and base_total_ex_tax <= 100 then "0 - 100"
when base_total_ex_tax > 100 and base_total_ex_tax <= 200 then "100 - 200"
when base_total_ex_tax > 200 and base_total_ex_tax <= 300 then "200 - 300"
when base_total_ex_tax > 300 and base_total_ex_tax <= 400 then "300 - 400"
when base_total_ex_tax > 400 and base_total_ex_tax <= 500 then "400 - 500"
when base_total_ex_tax > 500 and base_total_ex_tax <= 600 then "500 - 600"
else "over 600"
END AS Kurv,
COUNT(*) as ordre
FROM orders
WHERE
created_at > '2017-01-01 00:00:00'
&&
status_id != 'canceled'
GROUP BY 1)
y ON x.Kurv = y.Kurv
、私はちょうど一週間グループを追加する必要があります。
ありがとうございます。
それは魅力的に機能しました! :-) どうも。 – RK4002