Skip to content

Instantly share code, notes, and snippets.

@Veenap
Last active May 22, 2020 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Veenap/ef96ad7c77e162fce49bee0e3b898aa2 to your computer and use it in GitHub Desktop.
Save Veenap/ef96ad7c77e162fce49bee0e3b898aa2 to your computer and use it in GitHub Desktop.
CREATE TABLE FIRST_REV_DATE_TABLE AS
SELECT
anonymous_id, rev_date as first_rev_date
FROM
(
SELECT anonymous_id,
DATE_TRUNC('d', sent_at) as rev_date,
RANK() OVER (PARTITION by anonymous_id ORDER BY sent_at DESC) as rank,
FROM
RUDDER.track
WHERE
event=’revenue’
)
WHERE
rank = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment