Skip to content
Advertisement

SQL order by a function with literal values

I want to order some SQL result using the result of a calculation. I can select this

So the syntax seems correct, but when I try to use it in the order by clause like this:

I get a syntax error. So what is the correct way of doing this? I’m using mariadb as backend, not sure if that makes any difference from normal mysql.

Advertisement

Answer

Just put the order by before limit order :

Here is a demo:

DEMO

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement