Re: simple division
От
Thomas Kellerer
Тема
Re: simple division
Дата
Msg-id
29902835-a789-9b23-b236-f74a929b3bc3@gmx.net
Ответ на
simple division (Martin Mueller)
Список
Дерево обсуждения
simple division Martin Mueller <martinmueller@northwestern.edu>
Re: simple division Thomas Kellerer <spam_eater@gmx.net>
Re: simple division "David G. Johnston" <david.g.johnston@gmail.com>
Re: simple division "Joshua D. Drake" <jd@commandprompt.com>
Re: simple division "David G. Johnston" <david.g.johnston@gmail.com>
Re: simple division Martin Mueller <martinmueller@northwestern.edu>
Re: simple division Thomas Kellerer <spam_eater@gmx.net>
Re: simple division Ron <ronljohnsonjr@gmail.com>
Re: simple division "David G. Johnston" <david.g.johnston@gmail.com>
Re: simple division Martin Mueller <martinmueller@northwestern.edu>
Re: simple division Rob Sargent <robjsargent@gmail.com>
Re: simple division Gavin Flower <GavinFlower@archidevsys.co.nz>
Re: simple division Rob Sargent <robjsargent@gmail.com>
Re: simple division Gavin Flower <GavinFlower@archidevsys.co.nz>
Re: simple division Geoff Winkless <pgsqladmin@geoff.dj>
Re: simple division Tom Lane <tgl@sss.pgh.pa.us>
Re: simple division Martin Mueller <martinmueller@northwestern.edu>
Re: simple division Gavin Flower <GavinFlower@archidevsys.co.nz>
Re: simple division Adrian Klaver <adrian.klaver@aklaver.com>
Re: simple division Gavin Flower <GavinFlower@archidevsys.co.nz>
Re: simple division Alvaro Herrera <alvherre@2ndquadrant.com>
Re: simple division Geoff Winkless <pgsqladmin@geoff.dj>
Re: simple division Raymond Brinzer <ray.brinzer@gmail.com>
Re: simple division Albrecht Dreß <albrecht.dress@arcor.de>
RE: simple division Igor Neyman <ineyman@perceptron.com>
Martin Mueller schrieb am 04.12.2018 um 21:29: > 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? In the expression 10/4 both numbers are integers. And an integer divsion does not yield decimals (that's the same as in every strongly typed programming language). I am not entirely sure what the SQL standard says about such an expression, but e.g. SQL Server, SQLite, Firebird and DB2 behave the same as Postgres. That is they apply integer division if all values are integers, and decimal division if at least one value is a decimal. To get a division of decimals you need to specify at least one value as a decimal, e.g. "select 10.0/4" or "select 10/4.0" whatever you prefer.
В списке pgsql-general по дате отправления