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 排序

你可能感兴趣的:(case when)