我想将我的ArticleID分类为up(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
答案 0 :(得分: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
我简化了您的测试代码:
祝你好运。