Skip to content Skip to sidebar Skip to footer

How Can I Order By According To Some Boolean Logic?

Say I have columns 'a' and 'b'. A record is deemed 'ready' if !a || b. How can I sort by this ready condition? I'm really rusty with SQL and I can't recall what would have been

Solution 1:

orderbycasewhen !a || b then0else1end

Solution 2:

You can put expressions in the ORDER BY clause.

ORDER BY (!a || b) ASC

Solution 3:

So you just want all rows where !a or b is true first? If so order by !a and then by b.

Post a Comment for "How Can I Order By According To Some Boolean Logic?"