Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to take values after the second space in Teradata SQL?

I have table in Teradata SQL like below:

col1
---------
4561 ABC New York
3256 ABC Berlin
129 ABC  Milano

And I need to take only values after the second space, plus be aware that the second word is always "ABC", so I need values after "ABC".
As a result I need something like below:

col1               col2
-------------------------------
4561 ABC New York | New York
3256 ABC Berlin   | Berlin
129 ABC  Milano   | Milano

How can I do that in Teradata SQL ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Using a regex approach:

SELECT col1, REGEXP_REPLACE(col1, '[^ ]+ [^ ]+ ', '') AS col2
FROM yourTable;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading