case when 排序

select PartnerId, CertificateId
  from sis_xj_xsjbxx
 ORDER BY CASE
            WHEN @SortField = 'PartnerId' AND @SortMethod = 'ASC' THEN
             PartnerId
          END ASC,
          CASE
            WHEN @SortField = 'PartnerId' AND @SortMethod != 'ASC' THEN
             PartnerId
          END DESC,
          
          CASE
            WHEN @SortField = 'CertificateId' AND @SortMethod = 'ASC' THEN
             CertificateId
          END ASC,
          CASE
            WHEN @SortField = 'CertificateId' AND @SortMethod != 'ASC' THEN
             CertificateId
          END DESC

case when 排序

posted on 2013-06-08 13:36  BIGBIRD大鸟  阅读(654)  评论(0编辑  收藏  举报