Skip to content
Advertisement

Oracle SQL query to get comma-separated string in single query

I have a data which is represented as below:

I have a query as follows which has to be tweaked to get parent and child names respectively

My output should look as follows:

I basically want to split the lk.name based on seperator (,) and 1st string before seperator is parentName and 2nd string after seperator is childName. If there are no seperators then its just the parentName.

Advertisement

Answer

You can use regexp_substr):

Here is a db<>fiddle.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement