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, ',',''))

nVector

posted on 13 Jul 18

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