Skip to content
Advertisement

Order By case when then with multiple ASC/DESC [closed]

Hope this question has not been ask already. My problem is :

Do you know how to do something like that

Advertisement

Answer

You need separate case expressions. I’m not sure what 1, 2, and 3 represent. Let me assume they are meant to put the results in the order of the CASE expressions:

A CASE expression returns a single type. For this purpose, I don’t recommend converting values to a single type. Instead, just use separate keys in the ORDER BY for the different groups.

I should also point out that some databases might have special functionality that would simplify some of this code.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement