I'm looking to find the first 2 purchases for every customer.
I have a table that looks something like this:
order_id customer_email grand_total purchase_date
There are many millions of rows in this table and I'm trying to look for an efficient way to grab the first two earliest records for each customer, so that I get a result set that looks something like this:
order_id customer_email purchase_date1 purchase_date2
I'm at a loss on how to do this efficiently.