I am trying to find out how many repeat customers there are in a store. I want to print out a table that says something like
1 | 500
2 | 200
3 | 10
Meaning 500 customers ordered once, 200 twice, etc...
If I run this query:
mysql_query("SELECT DISTINCT COUNT(*) as theCount FROM orders GROUP BY user_id ORDER BY theCount");
I get the numbers 1,2,3 for the different amount of times people ordered. If I don't use distinct I get 500 rows with 1, 200 rows with 2, etc.
Once I grab 1, 2, and 3, I am not sure what to do with them to get the next numbers. I can't do WHERE COUNT(*)=5 so that is throwing me off.