A Question on TRIM Function

Database
Enthusiast

A Question on TRIM Function

Hi All,

 

I am trying to trim the leading comma in a string, the code I used is 

SEL TRIM(LEADING ',' FROM ' , , , , , , , , , , , , , , , , , , , , , , , , , , 2');

But the result is still 1.PNG


Could someone point me the reason?

Thanks in advance! 

 

Tags (1)
3 REPLIES
Junior Contributor

Re: A Question on TRIM Function

In your example there's a space between the commas.

LTRIM is capable of trimming multiple characters (regardless of order):

lTrim(' , , , , , , , , , , , , , , , , , , , , , , , , , , 2', ', ')

 

Teradata Employee

Re: A Question on TRIM Function

It looks to me that the reason is that you have no leading commas. The leading character is a space.

 

If instead you had

SEL TRIM(LEADING ',' FROM ',,,,,,,,,,,,,,,,,,,,,,,,,,2')

Then the result is 2.

Enthusiast

Re: A Question on TRIM Function

Thanks Dieter! That works!

 

Regards

Tags (1)