How to use Teradata OTRANSLATE() function - syntax ?

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

Table

\n\n
id  attribute\n1   strength, power\n2   ring, wig, puff

I need to count the number of commas

\n\n
id  att_number\n1   2\n2   3


Solution:

Using Teradata's Otranslate function:

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

nVector

posted on

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds