Re: Format an Update with calculation - Mailing list pgsql-general

From Condor
Subject Re: Format an Update with calculation
Date
Msg-id 85cdf83ed6473eb48dc1a66c44f55c61@stz-bg.com
Whole thread Raw
In response to Re: Format an Update with calculation  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: Format an Update with calculation  (Ron <ronljohnsonjr@gmail.com>)
List pgsql-general
On 18-12-2018 15:51, Adrian Klaver wrote:
> On 12/17/18 11:14 PM, Bret Stern wrote:
>> My statement below updates the pricing no problem, but I want it to be
>> formatted with 2 dec points eg (43.23).
>>
>> Started playing with to_numeric but can't figure it out. Lots of
>> examples with to_char in the
>> manual, but still searching for answer.
>>
>> Can it be done?
>>
>> I want suggested_retail_price to be formatted to 2 decimal points
>>
>> UPDATE im_ci_item_transfer
>>     SET suggested_retail_price=(suggested_retail_price +
>> (suggested_retail_price * .13))
>> WHERE item_code='0025881P2';
>>
>> Feeling lazy, sorry guys
>
> In addition to what Pavel posted:
>
> select round(43.2335, 2);
>
>  round
> -------
>  43.23


Beware with round and numeric

select round(43.2375, 2);
  round
-------
  43.24


  select 43.2375::numeric(17, 2);
  numeric
---------
    43.24

Regards,
HS


pgsql-general by date:

Previous
From: Torsten Förtsch
Date:
Subject: Re: conditionally terminate psql script
Next
From: Mike Martin
Date:
Subject: How to compare dates from two tables with blanks values