Answer the question
In order to leave comments, you need to log in
How to sort by three fields as expected?
Greetings.
The table has three fields:
SELECT * FROM Table ORDER BY score DESC, distance ASC, peoples DESC
Answer the question
In order to leave comments, you need to log in
formulate a criterion that matches your expectations and sort by its value
I don't know, of course, but maybe it will work?
SELECT * FROM Table where max(score) and min(distance) and max(peoples);
You can try sorting in excel)
In general, order by with a list of sorting criteria sounds exactly like sorting first by the first criterion inside the same - by the second and so on ...
And what you want - it suggests itself as the first criterion - something synthetic from all three criteria. For example, if these metrics are represented as coordinate axes, then the distance from the origin can be used as a synthetic metric - that is, the square root of the sum of squares (in this case, the root can be excluded for ordering).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question