Skip to content

Instantly share code, notes, and snippets.

@andrewpbrett
andrewpbrett / ofn-global-stats.sh
Created May 3, 2021 18:58 — forked from mkllnk/ofn-global-stats.sh
OFN global key stats
sql='
SELECT
SUBSTRING(CONCAT(completed_at) from 1 for 7) AS month,
COUNT(DISTINCT distributor_id) AS shops,
COUNT(DISTINCT email) AS customers,
COUNT(o.id) AS orders,
SUM(o.total) AS VALUE
FROM spree_orders o
WHERE o.completed_at >= DATE_TRUNC($$year$$, now() - interval $$1 year$$)
AND o.state = $$complete$$ GROUP BY month ORDER BY month;