Skip to content
Advertisement

Parse out word between two characters SQL Netezza

I am having trouble finding the correct syntax to parse out a word between two characters in Netezza.

PATIENT_NAME
SMITH,JOHN L
BROWN,JANE R
JONES,MARY LYNN

I need the first name which is always after the comma and before the first space. How would I do this in Netezza?

Advertisement

Answer

I think Netezza supports regexp_extract(). That would be:

select replace(regexp_extract(name, ',[^ ]+'), ',', '')

Or regexp_replace():

select regexp_replace(name, '^[^,]+,([^ ]+)( |$).*$', '1')
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement