I have a column which contains data like this
1 Virginia - VA,Maryland -MD,null
2 California - CA,Nebraska - NE,Minnesota - MN
3 Wyoming - WY,null,null
and so forth.
Is there a way i can modify the column using string functions to look like this from plain sql?
1 VA,MD
2 CA,NE,MN
3 WY
Assuming there’s nothing you can do with respect to your data, you can extract those values using
REGEXP_REPLACE:Here’s a working DEMO.