Good job! Let's say we want to calculate the global lifetime conversion rate. In other words, we want to know the percentage of registered customers who've made at least one purchase. This is a good indicator of the general condition of our business.
To calculate the rate, we first need to find the total number of customers and the number of customers who've made at least one purchase. That's quite straightforward:
COUNT(FirstOrderId) AS CustomersWithPurchase,
COUNT(*) AS AllCustomers
COUNT(*) counts all rows in a table (in this case, all the customers), while
COUNT(Column) only counts non-
NULL values in the specified column. Customers who didn't make any purchases have
FirstOrderId values, so they won't be added to the