From: | "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com> |
---|---|
To: | Martin Mueller <martinmueller(at)northwestern(dot)edu>, pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: simple division |
Date: | 2018-12-04 20:38:07 |
Message-ID: | dd63a926-6711-b795-6485-5029b9556213@commandprompt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 12/4/18 12:29 PM, Martin Mueller wrote:
>
> I have asked this question before and apologize for not remembering
> it. How do you do simple division in postgres and get 10/4 with decimals?
>
> This involves cast and numeric in odd ways that are not well explained
> in the documentation. For instance, you’d expect an example in the
> Mathematical Functions. But there isn’t.
>
> The documentation of string functions is exemplary. The documentation
> of mathematical less so. Remember that it may be used by folks like me
> whose math is shaky. The MySQL documentation is better on this simple
> operation.
>
I may be misunderstanding the question but:
select cast(x/y as numeric(10,4));
JD
> -----
>
> Martin Mueller
> Professor emeritus of English and Classics
>
> Northwestern University
>
--
Command Prompt, Inc. || http://the.postgres.company/ || @cmdpromptinc
*** A fault and talent of mine is to tell it exactly how it is. ***
PostgreSQL centered full stack support, consulting and development.
Advocate: @amplifypostgres || Learn: https://postgresconf.org
***** Unless otherwise stated, opinions are my own. *****
From | Date | Subject | |
---|---|---|---|
Next Message | Igor Neyman | 2018-12-04 20:38:15 | RE: simple division |
Previous Message | Allan Kamau | 2018-12-04 20:36:03 | Geographic coordinate values format conversion to DD (Decimal Degrees) format |