Jump to content

order by with conditions


praveenhotha

Recommended Posts

Hi,

 

its a bit tricky. I tried to implement the order by what you said. I figured out that you can use an expression in your ORDER BY clause.

With the expression you can do the DESC order with 0s coming to first.

 

Heres the query. I hope it helps.

SELECT number FROM temptable
ORDER BY number=0 DESC, number DESC;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.