Order by Points but if the same order by in MySQL

I now have my table results ordered by points. But it needs to be order by points but if this is the same than order by Difference.

Now is have is this:

... ORDER BY Points DESC";

But i want to have something like this:

... ORDER BY Points (if two have the same amount) Than ORDER BY Goal Difference

Hope you can help


It would help if you included the full query in your question. The order by clause can accept multiple arguments. As you phrase the question, the answer would be something like:

order by Points desc, GoalDifference

You might want an expression:

order by Points, t1.Goals - t2.Goals

These are also allowed in the order by.

The correct answer is: Thanks!

ORDER BY Points DESC, Goal Difference DESC

This works for me

When you order by two columns it takes the first column and for equal values of the first column it will order by the second one, so it just do what you need here.

You can use: order by Points, GoalDifference

or you can even do it in diferent orders:

order by Points DESC, GoalDifference

order by Points, GoalDifference DESC

You can always refer to the MYSQL Documentation:


This link its from an older version but it haven't changed for the other versions.

Need Your Help

R Quantstrat & Shiny: getSymbols error

r shiny quantmod shiny-server quantstrat

I am trying to create a Shiny app using quanstrat. The code runs flawlessly under normal conditions; however, when I put it in Shiny it fails. When running the code below, I get:

Android - Pick shortcut - I get shortcut intent and title but can't get shortcut icon

android icons shortcut

I already wrote a working code for showing a list of all available shortcuts from all apps and capturing the intent for the chosen shortcut as weell as the name of the app and the shortcut. But I c...