I am on phpmyadmin, and I have data:
query url score
a www.google.com 3
a www.facebook.com 2
a www.google.com 1
I want to ‘group’ entries by their domain, and then order (desc) the domain groups by each group’s highest score (some in the comments have found this wording clearer: ‘order desc by each group’s highest score’) so I get:
query url score
a www.google.com 3
a www.google.com 1
a www.facebook.com 2
Trying: select * from table order by score desc, url asc doesnt work. It gives (no apparent change):
query url score
a www.google.com 3
a www.facebook.com 2
a www.google.com 1
I’m apparently not communicating my troubles clearly. If you can see where I can make it clearer, let me know.
For reference, I have re-posed the question here and it has an accepted answer: How do I order groups by each group's highest value
2
Answers
If i understand, you want order by var1 first as asc and then by var2 as desc.
What about this:
According to your expected output, you don’t need grouping at all, just a multiple column
order by
clause: