Instruction
Well done! So far, we've only compared the number of customers who've made or didn't make a purchase. Now, we'd like to go deeper and analyze how much time customers take between registration and their first purchase. Check out the following query:
SELECT customer_id, first_order_date - registration_date AS days_to_first_order FROM customers;
Result:
| customer_id | days_to_first_order |
|---|---|
| 1 | 5 |
| 2 | 3 |
| 3 | 0 |
| 4 | NULL |
| ... | ... |
In the second column, we created an interval end_date - start_date to calculate the interval between the user's registration and their first order.
Exercise
Show customers' emails and interval between their first purchase and the date of registration. Name the column difference.
Observe how the database displays the difference between two dates. Note that each database engine displays intervals differently.
Stuck? Here's a hint!




