Skip to content

Instantly share code, notes, and snippets.

@narayana1208
Forked from robertjmoore/gist:3960013
Last active August 29, 2015 14:07
Show Gist options
  • Select an option

  • Save narayana1208/2e11325863bc8e7e8952 to your computer and use it in GitHub Desktop.

Select an option

Save narayana1208/2e11325863bc8e7e8952 to your computer and use it in GitHub Desktop.
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