I have a ‘suggests’ table with the following structure:
id(suggest_id) | author_id | accepted(true/false)
I want to order by the biggest acceptance rate, for example:
Jack had 10 suggests and he accepted 5 (50% acceptance rate)
John had 20 suggests and he accepted 5 (25% acceptance rate)
Steve had 10 suggests and he accepted 8 (80% acceptance rate)
This will return: Steve, Jack and John.
I think it’s probably have to be with two SQL queries, one for number of suggests and the second for accepted=true.
Maybe it can be done with one query?
I’m using rails, so it can be done by rails as well.
Depending on how you’re representing accepted (true/false) something like…