This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |