Archives of the TeradataForum
Message Posted: Mon, 02 Jul 2007 @ 19:29:17 GMT
Subj: | | Re: The last occurance of a character |
|
From: | | Michael Larkins |
Anomy:
I wrote the following select based on the limited data you have provided. It assumes that the longest string you might encounter is 3
characters long (substring backs up 4 from the length of the string-can be adjusted if needed). It also assumes a VARCHAR (I called col),
otherwise add a TRIM/TRAILING to the column used in the substrings.
sel col,substring(substring(col from char(col)-4) from 1+position('_' in
substring(col from char(col)-4)))
from strings
You can use this substring in your CASE.
Hope this helps,
Michael Larkins
Certified Teradata Master
Certified Teradata SQL Instructor
|