Using CASE statement in ORDER BY clause Sql 2005
Posted on 2010-08-18
Hi, I have a set of rows that I need to sort them in order by using case statement.
How can this be done?
entity, sales, psales,tsales ( columns )
sorting criteria ( way I need to ouput results)
when entity sales > 0 and tsales > 0, then tsales + psales desc
when entity sales = 0, then tsales + psales desc
when entity sales > 0 and tsales = 0, then sales+psales desc
would order by group similar rows ( based on above ) and sort them in 3 different ways ?