我有这个Order By声明:
ORDER BY
CASE WHEN @SortID = 1 AND @SortDirection = 'ASC' THEN ProjectID END ASC,
CASE WHEN @SortID = 1 AND @SortDirection = 'DESC' THEN ProjectID END DESC
我有另一个名为DateSort的列。我需要的是:
当@SortID = 1和@SortDirection =' ASC' ...我想按ProjectID ASC,DateSort ASC
排序当@SortID = 1和@SortDirection =' DESC' ...我想按ProjectID DESC,DateSort ASC
排序即。无论ProjectID是按ASC还是DESC排序,我都希望记录也按DateSort ASC排序
答案 0 :(得分:0)
这不起作用吗?
ORDER BY
CASE WHEN @SortID = 1 AND @SortDirection = 'ASC' THEN ProjectID END ASC,
CASE WHEN @SortID = 1 AND @SortDirection = 'DESC' THEN ProjectID END DESC,
DateSort ASC