Advertisement
perminovsm

Untitled

Apr 1st, 2024
607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. first_values AS (
  2.     SELECT DISTINCT(user_id),
  3.            FIRST_VALUE(a.first_date) OVER (PARTITION BY a.user_id ORDER BY a.datetime) AS first_date,
  4.            FIRST_VALUE(c.city_name) OVER (PARTITION BY a.user_id ORDER BY a.datetime) AS first_city,
  5.            FIRST_VALUE(c.city_id) OVER (PARTITION BY a.user_id ORDER BY a.datetime) AS city_id
  6.     FROM analytics_events a
  7.     LEFT JOIN cities c ON a.city_id = c.city_id
  8.     WHERE event = 'authorization'
  9.           AND a.user_id IS NOT NULL
  10.           AND a.log_date <= '2021-07-02'
  11.           AND a.first_date <= '2021-06-26'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement