a_khuzina

SQL_mistake_3

May 12th, 2022 (edited)
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT SUM(o.total_amt) / COUNT(DISTINCT o.user_id) ltv,
  2.        DATE_TRUNC('month', u.created_at::TIMESTAMP) create_date
  3. FROM tools_shop.orders o
  4. JOIN tools_shop.users u ON o.user_id=u.user_id
  5. GROUP BY DATE_TRUNC('month', u.created_at::TIMESTAMP)
Add Comment
Please, Sign In to add comment