13 July 2018        Add to Favorites   Report

How to use Teradata OTRANSLATE() function - syntax ?

Example Scenario: How to count the number of commas in a column

Table

id  attribute
1   strength, power
2   ring, wig, puff

I need to count the number of commas

id  att_number
1   2
2   3


Solution:

Using Teradata's Otranslate function:

CHAR_LENGTH(col) - CHAR_LENGTH(OTRANSLATE(col, ',',''))


Copied