pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Bret Stern <bret_stern@machinemanagement.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Format an Update with calculation
Date: Tue, 18 Dec 2018 13:49:55 +0000
Message-ID: <87pntzvtip.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <1545117297.4397.18.camel@dell990-bret-centos.localdomain>
References: <1545117297.4397.18.camel@dell990-bret-centos.localdomain>

>>>>> "Bret" == Bret Stern <bret_stern@machinemanagement.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)




view thread (9+ messages)  latest in thread

Message-ID: <87pntzvtip.fsf@news-spur.riddles.org.uk>
Permalink:  ../87pntzvtip.fsf@news-spur.riddles.org.uk/
Also on:    postgresql.org/message-id/87pntzvtip.fsf@news-spur.riddles.org.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: andrew@tao11.riddles.org.uk, bret_stern@machinemanagement.com
  Subject: Re: Format an Update with calculation
  In-Reply-To: <87pntzvtip.fsf@news-spur.riddles.org.uk>
  References: <1545117297.4397.18.camel@dell990-bret-centos.localdomain> <87pntzvtip.fsf@news-spur.riddles.org.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox