All Forums Database
gkk 22 posts Joined 11/10
04 Dec 2010
How to retrive the last word in the Sentence in Teradata ?

Hai...
i am new to Teradata . my objective is to retrieve the last word in the sentence with out hard coding . i got the sql query in Oracle but don't know how to accomplish the same in Teradata Sql. i am posting the Oracle Sql systax for retrieving the last word in the sentence .
SQL>
SELECT SUBSTR(sentence_column, INSTR(sentence_column,' ',-1) + 1)
FROM Text_table;

column : sentence_column, data type : varchar2(100)
Eg data :
1 All information must be store in table as data values
2 All views that are theoretically updateable are also updateable by the system.
3 The integrity constraints should store in the system catalog or in the database.

etc...

O/P : values
system
database

I need it in Teradata Sql query , please kindly help me . Thanks in Advance .

Thanks & Regards ,
Kiran

Tags:
WAQ 158 posts Joined 02/10
05 Dec 2010

INSTR equilant in Teradata is INDEX or POSITION.
have a look at this:
http://forums.teradata.com/forum/database/finding-the-index-of-last-occurrence

gkk 22 posts Joined 11/10
07 Dec 2010

Hai , Either of the two teradata functions INDEX and POSITION Syntax has NO negative integer option to search for a sub sting from back of the main string .

Thanks for responding ,
Kiran

gkk 22 posts Joined 11/10
10 Dec 2010

Hai Teradata Professionals,
Please someone solve my doubt i am waiting from many days .

Thanking you all in advance,
kiran

Jimm 298 posts Joined 09/07
11 Dec 2010

Take a look at the link WAQ provided. This tells you how to use the Oracle UDF's to find it in Teradata.

You must sign in to leave a comment.