How do I nest these if statements to return a single dataset where chargeType is determined by the description. This is an ETL script to take from source and map various descriptions to an optionset the destination system expects.
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;
Example Data
| invoiceNumber | Description | ChargeType |
|---|---|---|
| 123 | net rental | License Fee |
| 456 | FBM Download | DLM |
| 789 | Balance of Minimum Guarantee | Licensee Fee |