Order By multiple cols

I’m trying to do an orderby with multiple columns and for some reason doesn’t like the fact that i want 2 of them in ASC and one in DESC
why could that be ?
“ORDER BY rst, sticky ASC, id DESC”

the first 2 to be asc and the third to be desc.

You need to specify the direction for each column:

ORDER BY rst ASC, sticky ASC, id DESC

What wrong result or error are you getting the leads you to believe something doesn’t like what you are doing?

The default direction is ASC, so, you don’t need to specify it.

i think i did
ORDER BY rst ASC, sticky ASC, id DESC
but nothing changed…
let me try again
(when i say it doesnt like i mean nothing is changing)

yep…tried again and still nothing changed… the sticky are first then are the id ones… the rst arent before them. in fact it is last of the last.

That statement tells us nothing. We are not there with you to know what’s not changing.

You will need to post some sample data and show what result you are getting and if it is not obvious, show what the expected result should be.

Most likely, your data is not stored using the proper data type and so it does not sort as expected. So, post your table definition as well.

1 Like

Yep, too difficult to say why without data. Perhaps see if you can replicate the scenario with different simpler data if you don’t want to share yours. You may be surprised with the results.

Sponsor our Newsletter | Privacy Policy | Terms of Service