Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
249 B
45
Indexable
Never
SELECT EXTRACT(YEAR FROM DATE_TRUNC('year' , CAST(o.created_at AS date))) AS year,
        ROUND(SUM(o.total_amt) / COUNT(DISTINCT p.user_id),2) AS arppu
FROM tools_shop.orders AS o
JOIN tools_shop.users AS p ON o.user_id = p.user_id
GROUP BY year;