sql - Remove subsequent duplicate string in a column of table -
i have table named event
id event_sequnce 1 a->c->b->b->b->c->b 2 d->d->a->d->c->a->a->c
i want remove subsequent duplicate letter column event_sequnce
so output table be
id event_sequnce 1 a->c->b->c->b 2 d->a->d->c->a->c
how write query achieve this?
you have use regex it:
select regexp_replace('d->d->a->d->c->a->a->c', '(\w\-\>)\1+', '\1', 'g');
update version
select regexp_replace(regexp_replace(textcat('d->d->a->d->c->a->a->c->c', '->'), '(\w\-\>)\1+', '\1', 'g'), '\-\>$', '');
Comments
Post a Comment