Skip to content

Instantly share code, notes, and snippets.

@maartenl
Last active December 12, 2015 06:28
Show Gist options
  • Save maartenl/4728930 to your computer and use it in GitHub Desktop.
Save maartenl/4728930 to your computer and use it in GitHub Desktop.
Transformation of DECODE to CASE - Example 2
-- provides percentage taxation
DECODE(tax_notice.taxtype ,'VAT',NVL(tax.vat, tax.general)
,'PROP',NVL(tax.property_tax, tax.general)
,'INC',NVL(tax.income_tax, tax.general)
,'TAR',NVL(tax.tariff, tax.general)
,tax.general)
-- changed to
CASE tax_notice.taxtype
WHEN 'VAT' THEN COALESCE(tax.vat, tax.general)
WHEN 'PROP' THEN COALESCE(tax.property_tax, tax.general)
WHEN 'INC' THEN COALESCE(tax.income_tax, tax.general)
WHEN 'TAR' THEN COALESCE(tax.tariff, tax.general)
ELSE tax.general
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment