0

I have a Table called Test with below values

ID Name Description
1  Xyz   Mumbai,Delhi

I want Sql query which will give output as below

ID Name Description
1  Xyz   Mumbai
1  Xyz   Delhi
jarlh
  • 42,561
  • 8
  • 45
  • 63
Ravi058
  • 29
  • 5

1 Answers1

0

You can use regexp_substr with '[^,]+' pattern as second argument to split the comma seperated string

with tab( ID, Name, Description ) as
(
 select 1,'Xyz','Mumbai,Delhi' from dual
)
select ID, Name, 
       regexp_substr(Description,'[^,]+',1,level)
       as Description
  from tab 
 connect by level <= regexp_count(Description,',')+1;

ID  NAME   DESCRIPTION
--  ----   -----------
1   Xyz    Mumbai
1   Xyz    Delhi
Barbaros Özhan
  • 59,113
  • 10
  • 31
  • 55