Search code examples
hana

Remove duplicate number from each row in SQL


I have this table:

A     B           C   
Abc.  Bcd.        1223     
Abc.  Bdh.        144777  

I want to remove duplicates from each row in C column. Output should be like:

A     B       C   
Abc.  Bcd.    123   
Abc.  Bdh.    147  

I am using SAP HANA so many functions of SQL does not work there.


Solution

  • Why not use regular expressions like here (Regex to remove duplicate letters)?

    select REPLACE_REGEXPR ('([A-Za-z0-9])\1+' in 'AA2234b23' 
                            WITH '\1' 
                            OCCURRENCE ALL) 
    from dummy;
    

    result: A234b23