I'm new to SQL. I've been practicing a lot recently. I've stumbled into this problem (please see imgur link)
How do I do the ff:
- Select/query the each degrees before a delimiter and show it in a new--column degrees (as shown in the table)
- For those without a degree, like example Mansoon Ahmed, reflect in column degrees as blank
Link to the Table--> https://imgur.com/TEP08NF
Thanks for all the help! Have a great day ahead!
CodePudding user response:
Use split_part()
to get the part before the string:
SELECT CASE WHEN strpos(col, ',') <> 0
THEN trim(split_part(col, ',', 1))
END AS degree
FROM tab;