Skip to content

Instantly share code, notes, and snippets.

@robertjmoore
Created October 26, 2012 17:12
Show Gist options
  • Save robertjmoore/3960013 to your computer and use it in GitHub Desktop.
Save robertjmoore/3960013 to your computer and use it in GitHub Desktop.
Sample Query for Raw Cohort Analysis Data
SELECT orders.customerid,
orders.transactiondate,
orders.transactionamount,
cohorts.cohortdate
FROM orders
JOIN (SELECT customerid,
Min(transactiondate) AS cohortDate
FROM orders
GROUP BY customerid) AS cohorts
ON orders.customerid = cohorts.customerid;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment