16.20 - Example: Decoding IDs Using NULL - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
16.20
Release Date
March 2019
Content Type
Programming Reference
Publication ID
B035-1145-162K
Language
English (United States)

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