SUBSTRING Function Examples | Teradata Vantage - Example: Searching for Car Serial IDs - Advanced SQL Engine - Teradata Database

SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-30
dita:mapPath
tpt1555966086716.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1145
lifecycle
previous
Product Category
Teradata Vantageā„¢

Suppose sn is a CHARACTER(15) field of Serial IDs for Automobiles and positions 3 to 5 represent the country of origin as three letters.

For example:

   12JAP3764-35421
   37USA9873-26189
   11KOR1221-13145

To search for serial IDs of cars made in the USA:

   SELECT make, sn 
   FROM autos 
   WHERE SUBSTRING (sn FROM 3 FOR 3) = 'USA';