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'); 

enter image description here

update version

select regexp_replace(regexp_replace(textcat('d->d->a->d->c->a->a->c->c', '->'), '(\w\-\>)\1+', '\1', 'g'), '\-\>$', ''); 

Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -