Q:

How to increment count of occurences of column value in MySQL

I have the following column names:

customer_email
increment_id
other_id (psuedo name)
created_at

increment_id and other_id will be unique, customer_email will have duplicates. As the results are returned I want to know what number of occurance of the email it is.
For each row, I want to know how many times thecustomer_email value has shown up so far. There will be an order by clause at the end for the created_at field and I plan to also add a where clause of where occurrences < 2
I am querying > 5 million rows but performance isn't too important because I'll be running this as a report on a  read-replica database from production. In my use case, I will sacrifice performance for robustness. 
| customer_email | incremenet_id | other_id | created_at          | occurances <- I want this |
|----------------|---------------|----------|---------------------|---------------------------|
| joe@test.com   | 1             | 81       | 2019-11-00 00:00:00 | 1                         |
| sue@test.com   | 2             | 82       | 2019-11-00 00:01:00 | 1                         |
| bill@test.com  | 3             | 83       | 2019-11-00 00:02:00 | 1                         |
| joe@test.com   | 4             | 84       | 2019-11-00 00:03:00 | 2                         |
| mike@test.com  | 5             | 85       | 2019-11-00 00:04:00 | 1                         |
| sue@test.com   | 6             | 86       | 2019-11-00 00:05:00 | 2                         |
| joe@test.com   | 7             | 87       | 2019-11-00 00:06:00 | 3                         |

A:

You can use variables in earlier versions of MySQL:
select t.*,
       (@rn := if(@ce = customer_email, @rn + 1,
                  if(@ce := customer_email, 1, 1)
                 )
       ) as occurrences
from (select t.*
      from t
      order by customer_email, created_at
     ) t cross join
     (select @ce := '', @rn := 0) params;

In MyQL 8+, I would recommend row_number():
select t.*,
       row_number() over (partition by customer_email order by created_at) as occurrences
from t;

