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')