Re: simple division

From: Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz>
To: Geoff Winkless <pgsqladmin(at)geoff(dot)dj>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: simple division
Date: 2018-12-05 12:45:10
Message-ID: 8135455f-2a19-b91f-5336-7824813e2762@archidevsys.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 06/12/2018 00:05, Geoff Winkless wrote:
> On Wed, 5 Dec 2018 at 09:13, Gavin Flower <GavinFlower(at)archidevsys(dot)co(dot)nz> wrote:
>> SELECT ceil(10/4.0);
>>
>> Is what you want for that example.
> Except that implies that "number of people who can fit in a car" is a
> real number, not a whole.
>
> IMO it's fundamentally broken that SQL doesn't cast the result of a
> divide into a numeric value - the potential for unexpected errors
> creeping into calculations is huge; however that's the standard and
> no-one's going to change it now.
>
> Having said that it's worth noting that those in the Other Place think
> that it's broken enough to go against the standard (they have a DIV b
> for integer divide and a/b for float).
>
> Geoff
>
If you divide one integer by another, then it is logical to get an
integer as as the answer.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Geoff Winkless 2018-12-05 12:54:41 Re: simple division
Previous Message Thomas Kellerer 2018-12-05 11:49:53 Re: surprising query optimisation