Re: simple division

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Martin Mueller <martinmueller(at)northwestern(dot)edu>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: simple division
Date: 2018-12-04 20:45:02
Message-ID: CAKFQuwZXO4WJqEbmWUtnCvDhRfVqYWbFx7bQ8D-Q-mxPRqEKgg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Dec 4, 2018 at 1:38 PM Joshua D. Drake <jd(at)commandprompt(dot)com> wrote:
> I may be misunderstanding the question but:
Indeed...
> select cast(x/y as numeric(10,4));

Your answer is 2.0 instead of the correct 2.5 - you need to cast
before the division, not after.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rob Nikander 2018-12-04 20:57:06 querying both text and non-text properties
Previous Message David G. Johnston 2018-12-04 20:42:29 Re: simple division