This content has been marked as final. Show 4 replies
1 person found this helpful
select cust.id, cust.name, cust.region from customer cust order by cust.sort_value, case cust.sort_value when 1 then cust.id end asc, case cust.sort_value when 1 then cust.name end desc, cust.region asc /
So you always want to sort by region, but sometimes you want to sort by other things first.
Here's one way to do that:
ORDER BY CASE WHEN cust.sort_value = 1 THEN cust.id END ASC , CASE WHEN cust.sort_value = 1 THEN cust.name END DESC , cust.region ASC