Skip to content

Instantly share code, notes, and snippets.

@nfarah86
Created February 24, 2021 06:52
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 nfarah86/b62c9a4188e150bb1df5373f5c322368 to your computer and use it in GitHub Desktop.
Save nfarah86/b62c9a4188e150bb1df5373f5c322368 to your computer and use it in GitHub Desktop.
Customers who added items to their shopping cart and did not purchase
-- Note: peak time is 14; we hardcorded because of the way the sample data is. Normally we would use current timestamp.
SELECT
ca.CustomerID, ca.CustomerEmail, ca._event_time
FROM
commons.CustomerActivity ca
WHERE
NOT EXISTS (
SELECT
oi.CustomerID
FROM
commons.OrderItem oi
WHERE
ca.CustomerID= oi.CustomerID) and ca._event_time > ((PARSE_TIMESTAMP_ISO8601('2021-01-25T16:23:29.000000Z')) - SECONDS(:timeElapsed));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment