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?

1
  • not very clear. You want to get rid of .00 from the end? Commented Dec 6, 2019 at 4:48

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.