Select BILL_ID,SUM(Case When DR_CR=1 Then AMT Else 0 End) as D_AMT, SUM(Case When DR_CR=2 Then AMT Else 0 End) as C_AMT From zhlx_baa.glb_ex_vou_detail Where MOF_DIV_CODE='530523000' and ACCT_SET_CODE='533323000_ACCT_2022_001' and FISCAL_YEAR=2022 and VOU_STATUS <>-9 and PRO_CODE='530523221100001069889' Group by BILL_ID
时间: 2023-04-01 10:01:31 浏览: 105
sql学习之CASE WHEN THEN ELSE END的用法
这是一个 SQL 查询语句,用于从 zhlx_baa.glb_ex_vou_detail 表中选择账单 ID、借方金额和贷方金额,并按账单 ID 进行分组。查询条件为 MOF_DIV_CODE='530523000'、ACCT_SET_CODE='533323000_ACCT_2022_001'、FISCAL_YEAR=2022、VOU_STATUS <>-9 和 PRO_CODE='530523221100001069889'。
阅读全文