0

我想将我的 ArticleID 向下排序(DESC)。我该如何编辑此代码来做到这一点?太感谢了

ORDER  BY CASE 
        WHEN @order = 'AddArticleType.ArticleID' THEN CONVERT(nvarchar,AddArticleType.ArticleID) 
        WHEN @order = 'Title' THEN CONVERT(nvarchar, Title) 
        WHEN @order = 'family' THEN CONVERT(nvarchar, family)
        WHEN @order = 'AddArticleType.ArticleType' THEN 
         CONVERT(nvarchar, AddArticleType.ArticleType ) 
      END 
4

1 回答 1

2

回到您之前帖子中@Gordon 的好答案,这应该有效:

ORDER  BY 
   CASE WHEN @order = 'AddArticleType.ArticleID' THEN AddArticleType.ArticleID END DESC,
   CASE WHEN @order = 'Title' THEN Title END,
   CASE WHEN @order = 'family' THEN family END,
   CASE WHEN @order = 'AddArticleType.ArticleType' THEN AddArticleType.ArticleType END

我已经简化了您的测试代码:

http://sqlfiddle.com/#!3/8a2d3/9

祝你好运。

于 2013-02-04T15:43:53.583 回答