Archives of the TeradataForum
Message Posted: Tue, 06 May 2008 @ 15:01:02 GMT
Subj: | | Re: Pattern matching in Teradata SQL |
|
From: | | Michael Larkins |
This approach was my first thought as well. However, I quickly realized that it would only work if the 'R' followed by the digits is the
first R in the string because POSITION stops at the first occurance. Therefore, if an R appears any where in any text before the R and digits, it
will miss that occurance.
> > sel COLUMN1 FROM TABLE_NAME
> > WHERE SUBSTRING (COLUMN1 FROM (POSITION('R' IN COLUMN1) ) FOR 2) BETWEEN
> > 'R0' AND 'R9'
> >
> > R followed by 2 digit:
> >
> > sel COLUMN1 FROM TABLE_NAME
> > WHERE SUBSTRING (COLUMN1 FROM (POSITION('R' IN COLUMN1) + 1) FOR 1)
> > BETWEEN '0' AND '9' and
> > SUBSTRING (COLUMN1 FROM (POSITION('R' IN COLUMN1) + 2) FOR 1) BETWEEN
> > '0' AND '9'
Regards,
Michael Larkins
Certified Teradata Master
Certified Teradata SQL Instructor
|