码迷,mamicode.com
首页 > 数据库 > 详细

T-SQL Case 嵌套 Case

时间:2015-11-24 11:10:02      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

SELECT JournalEntryId,
       JournalEntryNo,
       CapitalChain,
       DataSource,
       EntrySummary,
       AccountSubject,
       CASE AccountSubject
         WHEN ‘应付账款‘ THEN ‘卡门网供应商‘
         WHEN ‘应收账款‘ THEN ‘卡门网客户‘
         WHEN ‘预收账款‘ THEN ( CASE
                              WHEN JournalEntryNo LIKE API%‘ THEN API预收客户款‘
                              WHEN JournalEntryNo = CSC004 THEN CSC预收客户款‘
                              WHEN JournalEntryNo = CSC005 THEN ‘卡门网预收客户款‘
                              WHEN JournalEntryNo LIKE KYS%‘ THEN ‘卡吧零预收客户款‘
                              WHEN JournalEntryNo LIKE ZH%‘ THEN ‘卡门网预收客户款‘
                              WHEN JournalEntryNo LIKE ZJC%‘ THEN ‘卡门网预收客户款‘
                            END )
         ELSE ‘‘
       END AS AccountSubjectDetail,
       DebitAmount*-1 AS DebitAmount,
       CreditAmount*-1 AS CreditAmount,
       OffsetCategory,
       CustomerSiteType,
       BusinessTypeId,
       JournalEntryTime,
       InputTime
FROM   dbo.JournalEntry
WHERE  JournalEntryTime >= 2015-08-23 00:00:00.000
       AND JournalEntryTime <= 2015-08-23 23:59:59.999
       AND AccountSubject IN (‘应收账款‘, ‘应付账款‘, ‘预收账款‘)
       AND CustomerSiteType = ‘外部站点‘

T-SQL Case 嵌套 Case

标签:

原文地址:http://blog.csdn.net/lee576/article/details/50009135

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!