Could anyone please help me and suggest a function/ expression/ operator in Teradata to write a query that would return a set of rows which include any single character between 'A-P'.
I'm looking for a operator like 'LIKE'.
I have tried regexp_like and regexp_similar but the results were not as expected.
Let me know in case any more details needed.
Standard SQL LIKE only supports
%, using ranges is characters is an extension (e.g. SQL Server).
What did you try?
regexp_like in Teradata, but
regexp_similar works fine:
WHERE REGEXP_SIMILAR(column, '.*[A-P].*', 'i') = 1
'c' for a case-sensitive search
The condition given by you using REGEXP_SIMILAR worked for me. I was missing out the '.*' part.
i had tried below query which worked for me:
case when SUBSTRING(column_name from 1 for 1) between 'A' and 'P' then column_name
where alias is not null;
but the approach given by you looks good.