Search Postgresql Archives

Re: simple division

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 most people think of me as a person with a reasonably good memory. There is no obvious place in the documentation to look this up.


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

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





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux