I have a table which stores IDs and the city where the store is located.
I want to list all the stores starting with the stores that are in the city where there are
This one calculates the count in a separate query, joins it and orders by that count (SQL-Fiddle):
SELECT c.id, c.city FROM cities c JOIN ( SELECT city, COUNT(*) AS cnt FROM cities GROUP BY city ) c2 ON ( c2.city = c.city ) ORDER BY c2.cnt DESC;