Skip to content
Advertisement

How to substring non constant strings?

I have the following query:

With this query I try to associate the value of substring to my variable NUMERO_ORDINE when I find the “NR.” string in the Text column.

Sometimes I don’t have the “NR.” string, so this query doesn’t work and I get wrong values from substring function.

How can I create the same substring when I don’t have the “NR.” string into Text? I always need to isolate nine numbers.

Advertisement

Answer

One method is to use a CASE expression:

You can also add the pattern to the end of the string when it is being searched:

This is a little tricky in this case because the pattern is a little complicated.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement