I am trying to sort a query using ORDER BY where I need to sort 3 columns one by one. And the third column is value specific.
Eg: If i have 3 columns a,b and c I need to use ORDER BY a, b desc, c='3' asc, c
What I want to do is first sort order is a, then b in desc order then I want the values of which has 3 to be sorted and then the remaining values which are not 3.
ORDER BY
a,
b desc,
CASE WHEN c = 3 THEN 0 ELSE 1 END,
c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With