| От | Michael Fuhr |
|---|---|
| Тема | Re: Casting issue with aggregated function |
| Дата | |
| Msg-id | 20060102165947.GA20396@winnie.fuhr.org обсуждение исходный текст |
| Ответ на | Casting issue with aggregated function ("Marc Mamin" <M.Mamin@intershop.de>) |
| Список | pgsql-general |
On Mon, Jan 02, 2006 at 11:18:53AM +0100, Marc Mamin wrote: > select sum(c) from > ( > select sum(25665800) as c > )foo > > => 25665800 (numeric) > > I find the cast form int8 to numeric being strange. It's documented to work that way: http://www.postgresql.org/docs/8.1/interactive/functions-aggregate.html The return type for sum() is "bigint for smallint or int arguments, numeric for bigint arguments, double precision for floating-point arguments, otherwise the same as the argument data type." Your subquery has an integer argument so its sum() returns bigint; you then feed that bigint to sum() so the result is numeric. Presumably the promotions are done to avoid overflow. -- Michael Fuhr
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера