From Gentle Prairie Dog, 4 Months ago, written in Plain Text, viewed 66 times.
URL http://codebin.org/view/a75e1ec3 Embed
Download Paste or View Raw
  2.   DATE_TRUNC('year', CAST(o.created_at AS date)) AS order_year,
  3.   ROUND(SUM(o.total_amt) / COUNT(DISTINCT u.user_id), 2) AS arppu
  4. FROM tools_shop.users u
  5. JOIN tools_shop.orders o ON o.user_id = u.user_id
  6. GROUP BY order_year
  7. ORDER BY order_year;

Reply to "Untitled"

Here you can reply to the paste above