0

I am removing part of a string in my column customer_id in Postgresql.

Customer_id : 

N12300 
245007.00 


UPDATE public.meltuniverse SET customer_id=trim(trailing '.0' FROM customer_id::varchar);

I only want to remove the .00 at the end and now it returns me :

N123
245007 

How i can fix this?

Simon GIS
  • 1,045
  • 2
  • 18
  • 37

1 Answers1

2

Use Regular Expressions:

UPDATE public.meltuniverse 
SET customer_id = regexp_replace(customer_id, '\.00$', '')

The pattern '\.00$' matches exact substring '.00' at the end of the string.

Db<>fiddle.

klin
  • 112,967
  • 15
  • 204
  • 232