Re: simple division - Mailing list pgsql-general

From Martin Mueller
Subject Re: simple division
Date
Msg-id 8B35EF9C-8DEF-4298-A646-89D1AC8F63E1@northwestern.edu
Whole thread Raw
In response to Re: simple division  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: simple division  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: simple division  (Ron <ronljohnsonjr@gmail.com>)
Re: simple division  (Albrecht Dreß <albrecht.dress@arcor.de>)
Re: simple division  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-general
I didn't formulate my question properly, because the query went like
 "select alldefects /wordcount" 
where alldefects and wordcount are integers.   But none of the different ways of putting the double colon seemed to
work.
 

The Postgres notation of this simple procedure is very unintuitive. I haven't been able to remember several times, and
mostpeople think of me as a person with a reasonably good memory. There is no obvious place in the documentation to
lookthis up.
 


On 12/4/18, 2:45 PM, "David G. Johnston" <david.g.johnston@gmail.com> wrote:

    On Tue, Dec 4, 2018 at 1:38 PM Joshua D. Drake <jd@commandprompt.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.
    


pgsql-general by date:

Previous
From: Rob Nikander
Date:
Subject: querying both text and non-text properties
Next
From: "David G. Johnston"
Date:
Subject: Re: simple division