Reputation: 153
There is an SQL
query with ORDER BY
:
ORDER BY someColumn DESC NULLS LAST, NULLIF(anotherColumn->>'someNumField', '')::float';
So, here are two types of sorting. First one is performed, then the second. I want the second sort to be performed under certain conditions.
How to do second sorting only if that value is not null
?
Upvotes: 0
Views: 117
Reputation: 76
Try using a CASE expression in your order by
ORDER BY someColumn DESC NULLS LAST, CASE when logic then 'a' else 'b' end
Upvotes: 2