Example: Decoding IDs Using NULL

Teradata Vantageā„¢ SQL Functions, Expressions, and Predicates

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1145-162K

The following query

SELECT DECODE(country_id, 1, 'United States', 
                          2, 'England')
    FROM customers; 

returns:

  • 'United States' if the country_id is 1
  • 'England' if country_id is 2
  • NULL if country_id isn't in the range 1 to 2