filmov
tv
Removing duplicate values from STRING using REGEXP_REPLACE | ORACLE | PLSQL | SQL | Interview Topic

Показать описание
This is one of the simple demonstration of how to remove Duplicates values from given STRING. Also one can know some main features of Oracle REGEXP.
Delimited can be anything and accordingly we need to update Expression.
In 19C and + we can directly use DISTINCT in LISTAGG.
PS: Can directly use below SQL Syntax for same.
SELECT
REGEXP_REPLACE('LAYMAN,LAYMAN,LAYMAN,YOUTUBE,YOUTUBE,PLSQL,PLSQL,SQL,SQL',
'([^,]+)(,\1)*(,|$)',
'\1\3') OP
FROM DUAL;
Delimited can be anything and accordingly we need to update Expression.
In 19C and + we can directly use DISTINCT in LISTAGG.
PS: Can directly use below SQL Syntax for same.
SELECT
REGEXP_REPLACE('LAYMAN,LAYMAN,LAYMAN,YOUTUBE,YOUTUBE,PLSQL,PLSQL,SQL,SQL',
'([^,]+)(,\1)*(,|$)',
'\1\3') OP
FROM DUAL;