Example

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 returns a result of 2. The 3-grams 'mit' and 'ith' match. Note that 'Smi' and 'smi' do not match because of the difference in case.

   SELECT NGRAM('John Smith','Allen smith 1',3); 

The following query returns a result of zero. There are no 3-grams in the first string expression of '' since the length of the string is less than 3.

   SELECT NGRAM ('','str1 empty',3); 

The following query returns a result of zero. There are no 0-grams in the strings.

   SELECT NGRAM ('test with zero length', 'test with zero length',0); 

The following query returns a result of 3. The 1-grams 'a', 'b', and 'c' match.

   SELECT NGRAM ('abc','yyabc',1); 

The following query returns a result of 2. The 2-grams 'ab' and 'bc' match.

   SELECT NGRAM ('abc','yyabc',2); 

The following query returns a result of zero. The 2-grams 'ab' and 'bc' match, but they are not within 1 position of each other.

   SELECT NGRAM ('abc','yyabc',2, 1); 

The following query returns a result of 2. The 2-grams 'ab' and 'bc' match, and they are within 2 positions of each other.

   SELECT NGRAM ('abc','yyabc',2, 2); 

The following query returns a result of 2. The 2-grams 'ab' and 'bc' match, and they are at the same position in each string.

   SELECT NGRAM ('abc','abc',2, 0); 

The following query returns a result of zero. There are no 5-grams since the length of either input string is less than 5.

   SELECT NGRAM ('abc','abc',5,0);