case when在sqlserver和oracle的不同寫法

來源:互聯網
上載者:User

---sqlserver寫法:SELECT COUNT(1),remark FROM (             SELECT   Remark=CASE  WHEN Remark LIKE '%CHECK TKT TIME%'  THEN '保留時間有問題' WHEN Remark LIKE '%WITH "AV" AGAIN%' THEN '沒有艙位' WHEN Remark LIKE 'DUPLICATE TEL NUMBER%' THEN '訂位授權OFFICE號重複'  WHEN Remark LIKE '%INVALID FOID%' THEN '證件號錯誤' ELSE '其他' end FROM JinRiLogger.dbo.UserOperateLog201307 WITH(NOLOCK) WHERE OperateType=8 ) AS  a GROUP BY a.Remark---oracle寫法:SELECTCASE   WHEN Remark LIKE '%CHECK TKT TIME%'  THEN '保留時間有問題' WHEN Remark LIKE '%WITH "AV" AGAIN%' THEN '沒有艙位' WHEN Remark LIKE 'DUPLICATE TEL NUMBER%' THEN '訂位授權OFFICE號重複' WHEN Remark LIKE '%INVALID FOID%' THEN '證件號錯誤' ELSE '其他' end,count(*)FROM JinRiLog.UserOperateLog partition (p2)where Operatetype=8group byCASE   WHEN Remark LIKE '%CHECK TKT TIME%'  THEN '保留時間有問題' WHEN Remark LIKE '%WITH "AV" AGAIN%' THEN '沒有艙位' WHEN Remark LIKE 'DUPLICATE TEL NUMBER%' THEN '訂位授權OFFICE號重複' WHEN Remark LIKE '%INVALID FOID%' THEN '證件號錯誤' ELSE '其他'end;


本文出自 “記錄點滴!” 部落格,請務必保留此出處http://ocpyang.blog.51cto.com/3401739/1300170

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.