Skip to content

Instantly share code, notes, and snippets.

@achad4
Created February 14, 2022 14:00
Show Gist options
  • Select an option

  • Save achad4/6c9b8d97d78b6408d65c90c70f01aaf8 to your computer and use it in GitHub Desktop.

Select an option

Save achad4/6c9b8d97d78b6408d65c90c70f01aaf8 to your computer and use it in GitHub Desktop.
Example of metrics query for article
WITH month_0 AS
(
SELECT user_id,
metric_a
FROM analytics_table
WHERE execution_date = < month_0 >
),
month_1 AS
(
SELECT user_id,
metric_a
FROM analytics_table
WHERE execution_date = < month_1 >
)
SELECT user_id,
ABS(m1.metric_a - m0.metric_a) AS abs_shift
FROM month_0 AS m0
INNER JOIN month_1 AS m1 USING (user_id)
WHERE abs_shift > < X >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment