根据条件将行转换为列需要oracle sql

bqjvbblv  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(192)

我有一个t1表,其中包含以下字段和数据

SETID   Emplid          ITEM_NBR        CLASS   ITEM_AMT   ITEM_TYPE_CD     ITEM_NBR_SOURCE         Descr                   ACCOUNT_NBR
KICAE   00000000261     000000000000001 0       100         C                                       Health Services         HTL0001
KICAE   00000000261     000000000000002 0       5           C               000000000000001         VAT                     VAT0001
KICAE   00000000261     000000000000003 10149   150         C                                       Book Fee (10149)        BOOK001
KICAE   00000000261     000000000000004 0       7.5         C               000000000000003         VAT                     VAT0001
KICAE   00000000261     000000000000005 10143   150         C                                       Book Fee (10143)        BOOK001
KICAE   00000000261     000000000000006 0       7.5         C               000000000000005         VAT                     VAT0001
KICAE   00000000261     000000000000007 10190   150         C                                       Book Fee (10190)        BOOK001
KICAE   00000000261     000000000000008 0       7.5         C               000000000000007         VAT                     VAT0001
KICAE   00000000261     000000000000009 0       350         C                                       Student Services        SSC0001
KICAE   00000000261     000000000000014 0       500         C                                       Registration Fees       REG0001
KICAE   00000000261     000000000000015 0       25          C               000000000000014         VAT                     VAT0001
KICAE   00000000261     000000000000016 10149   2700        C                                       Principles of Economics TUT001
KICAE   00000000261     000000000000017 0       135         C               000000000000016         VAT                     VAT001
KICAE   00000000261     000000000000018 10143   3000        C                                       Operations Management   TUT001
KICAE   00000000261     000000000000019 0       150         C               000000000000018         VAT                     VAT001
KICAE   00000000261     000000000000020 10190   7000        C                                       TOEFL Package 1         TUPC001
KICAE   00000000261     000000000000021 10149   -27         W                                       Reduction in VAT Waiver VAT001
KICAE   00000000261     000000000000022 10143   -30         W                                       Reduction in VAT Waiver VAT001
KICAE   00000000261     000000000000023 10149   -540        W                                       Discount                TUT001
KICAE   00000000261     000000000000024 10143   -600        W                                       Discount                TUT001

我想显示两个不同的字段“vat”&折扣vat值与项目\u nbr\u来源链接,并且始终为5%项目类型代码=c(费用),w=放弃折扣值和vat减少与类别链接。应显示“增值税”和“折扣”的任何行。“折扣”和“增值税”列中应显示课程标题为“增值税”和课程标题为“折扣”的行的项目金额。商品编号来源告诉我们该费用的来源商品编号(c)该商品的类型是折扣和增值税折扣。帐户为\u nbr=tut001且项目类型为\u cd='c'的项目仅提供折扣
结果是:

ITEM_NBR        Class   Descr                       ITEM_AMT       Discount     VAT(5%)   
000000000000001 0       Health Services             100             0            5
000000000000003 10149   Book Fee (10149)            150             0            7.5
000000000000005 10143   Book Fee (10143)            150             0            7.5
000000000000007 10190   Book Fee (10190)            150             0            7.5
000000000000009 0       Student Services            350             0            17.5
000000000000014 0       Registration Fees           500             0            25.0
000000000000016 10149   Principles of Economics     2700            540          135
000000000000018 10143   Operations Management       3000            600          150
000000000000020 10190   TOEFL Package 1             7000            0            350
000000000000021 10149   Reduction in VAT Waiver     540             0            27
000000000000022 10149   Reduction in VAT Waiver     600             0            30

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题