T-SQLCase嵌套Case

页面导航:首页 > 数据库 > MsSql > T-SQLCase嵌套Case

T-SQLCase嵌套Case

来源: 作者: 时间:2016-01-20 09:48 【

SELECT JournalEntryId, JournalEntryNo, CapitalChain, DataSource, EntrySummary, AccountSubject, CASE AccountSub
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 = '外部站点'
Tags:

相关文章

    文章评论

    最 近 更 新
    热 点 排 行
    Js与CSS工具
    代码转换工具
    
    <