Using a case-then block, I need to choose how to order my SQL 2008 query, by [status] ASC, [date] DESC
or just [date] DESC
.
I know only how to use one column:
SELECT *
FROM table
ORDER BY
CASE WHEN @flag = 0
THEN R.[date] END DESC,
CASE WHEN @flag = 1
THEN R.[status] END ASC
How to use both columns in second CASE?