CASE WHEN statement for ORDER BY clause
CASE is an expression – it returns a single scalar value (per row). It can’t return a complex part of the parse tree of something else, like an ORDER BY clause of a SELECT statement. It looks like you just need: ORDER BY CASE WHEN TblList.PinRequestCount <> 0 THEN TblList.PinRequestCount END desc, CASE WHEN TblList.HighCallAlertCount … Read more