Sorry my English is not the best.
Is it possible to make "where" in "order by".
Example:
ORDER BY SUM(points), SUM(points) WHERE type = 1, SUM(goal), SUM(goal) WHERE type = 1
So, first we sort by points.
If someone has the same number of SUM(points) , then sort by SUM(points) where type = 1 .
If someone has the same number of SUM(points) and the same number of SUM(points) where type = 1 , then we sort after SUM(goal) .
If someone has the same thing in all 3, then he should sort by SUM(goal) where type = 1 .
source share