Replace the second repeated character

0

I have the following value in an Oracle query.

SELECT '3.0.' FROM DUAL

I would like it to return only 3.0 and remove the Last Point (.)

I tried using REGEXP_REPLACE like this:

SELECT REGEXP_REPLACE('3.0.','(.){2,.}','') FROM DUAL

But it did not work. Can you help me?

    
asked by anonymous 15.02.2018 / 16:01

2 answers

1

You can use Oracle's TRIM function.

Leaving the query this way:

SELECT TO_CHAR(TRIM(TRAILING . FROM campo))
FROM tabela
WHERE condições
    
15.02.2018 / 16:15
1

You can do with SUBSTR , removing the last one character:

SELECT SUBSTR(VALOR, 0, LENGTH(VALOR)-1) FROM (SELECT '3.0.' VALOR FROM DUAL);

See working in SQL Fiddle .

    
15.02.2018 / 16:24