Let there be two tables, one holding user information and one holding user records of some sort, say receipts. There is a one-to-many relationship between the users and receipts.
What would be the best SQL method of retrieving users, sorted by the greatest number of receipts?
The best way I can think of is using a join and count(?) to return an array of users and their number of associated receipts.
Is there a way to make use of the count function in this instance?
select * from `users` inner join `receipts` on `users`.`id` = `receipts`.`uId`