Saturday, April 23, 2016

Opposite to ListAgg Function

Example: (single Record)
 Single record 'Trinesh,Shanthi,Tejesh,Vasavi' need to convert into 4 records as follows
Trinesh
Shanthi
Tejesh
Vasavi 
using simple SQL query.

Query:
SELECT REGEXP_SUBSTR('Trinesh,Shanthi,Tejesh,Vasavi','[^,]+',1,LEVEL) NAMES FROM DUAL
CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE('Trinesh,Shanthi,Tejesh,Vasavi','[^,]+'))+1

Example: (Multiple Record)

Source:

 Query:




No comments:

Post a Comment