Untitled

From Abrupt Guinea Pig, 4 Months ago, written in SQL, viewed 69 times.
URL http://codebin.org/view/0d8a122a Embed
Download Paste or View Raw
  1. SELECT DISTINCT DATE_TRUNC('month', event_time)::DATE AS mnth
  2.     , COUNT(event_id) OVER(PARTITION BY DATE_TRUNC('month', event_time)::DATE
  3.                     ORDER BY DATE_TRUNC('month', event_time)::DATE) AS count_month
  4.     , COUNT(event_id) OVER(ORDER BY DATE_TRUNC('month', event_time)::DATE) AS count_month_cum
  5. FROM tools_shop.events e
  6.     JOIN tools_shop.users u ON e.user_id = u.user_id
  7.     JOIN tools_shop.orders o ON u.user_id = o.user_id
  8. WHERE event_name = 'view_item'

Reply to "Untitled"

Here you can reply to the paste above