Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Data Tranformation

Status
Not open for further replies.

sunnyphoenixier

Technical User
Dec 3, 2003
45
US
I have a field with values like "Summer 2005", I need to translate that into "Summer 2004", basically, to the same text + last year.

I know that in Oracle, I can do LTRIM, RTRIM and CANCATENATE, etc., but I cann't figure it out in Teradata. Any help will be greatly appreciated.

Thanks,

Phoenixier
 
If there is ALWAYS a space between the word and number, you can use INDEX to locate it.

SUBSTR(column_name, 1 , (INDEX(column_name, ' '))-1) subtract 1 to get to the end of the word.

If there are other spaces in the column before the year, you will have to use the INDEX function to look for a 2 and subtract 2 from that position.
 
LTRIM -> TRIM(LEADING FROM col)
RTRIM -> TRIM(TRAILING FROM col)
CONCAT(c1, c2) -> c1 || c2
INSTR(str, substr) -> POSITION(substr IN str)
SUBSTR(col,2,3) -> SUBSTR(col,2,3) or SUBSTRING(col FROM 2 FOR 3)

;-)

Dieter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top