You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何嵌套SQL语句实现按Description映射ChargeType并返回单一数据集

需求说明

需嵌套条件语句,返回一个根据description字段确定ChargeType的单一数据集。这是一个ETL脚本,用于从源端提取数据,并将各类description映射到目标系统所需的选项集。

原代码
if (invoice_detail.description like 'Net Rental' or invoice_detail.description like 'Balance of Minimum Guarantee') 

    Select
        id.code_invoice,
        'License Fee' as ChargeType,
        id.amount,
        id.vat_amount,
        id.original_amount,
        id.original_amount - id.original_vat_amount as netTotal
        
        from invoice_detail id order by code_invoice desc;
         
        
if  (invoice_detail.description like 'FBM Download')

    Select
        id.code_invoice,
        'DLM' as ChargeType,
        id.amount,
        id.vat_amount,
        id.original_amount,
        id.original_amount - id.original_vat_amount as netTotal
        
        from invoice_detail id order by code_invoice desc;
示例数据
发票编号(invoiceNumber)描述(Description)费用类型(ChargeType)
123net rentalLicense Fee
456FBM DownloadDLM
789Balance of Minimum GuaranteeLicensee Fee

内容的提问来源于stack exchange,提问作者user2903459

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 11:01:22