Re: Format an Update with calculation

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: Bret Stern <bret_stern(at)machinemanagement(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Format an Update with calculation
Date: 2018-12-18 13:49:55
Message-ID: 87pntzvtip.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>>>>> "Bret" == Bret Stern <bret_stern(at)machinemanagement(dot)com> writes:

Bret> My statement below updates the pricing no problem, but I want it
Bret> to be formatted with 2 dec points eg (43.23).

UPDATE ...
SET suggested_retail_price = round(suggested_retail_price*1.13, 2)
WHERE ...

assuming suggested_retail_price is already of type "numeric".

You could also have given the columm a type of numeric(18,2) or similar,
which would round all assigned values to 2 places.

--
Andrew (irc:RhodiumToad)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-12-18 13:51:16 Re: Format an Update with calculation
Previous Message Chris Mair 2018-12-18 10:57:09 Re: How to insert bulk data with libpq in C?