Vadim B. Mikheev wrote:

(790 is OID of money)

vac=> select * from pg_aggregate where aggbasetype = 790;
aggname|aggowner|aggtransfn1|aggtransfn2|aggfinalfn|aggbasetype|aggtranstype1|aggtranstype2|aggfinaltype|agginitval1|agginitval2
-------+--------+-----------+-----------+----------+-----------+-------------+-------------+------------+-----------+-----------
avg | 1000|cash_pl |float8inc | -| 790| 790| 701| 790| | 0.0
^^^^^^^^^
float8div ????
No, the increment is OK. aggfinalfn needs to set to be a function which divides cash by float and returns cash. Could probably
substitute integers for the floats without ill effect since cash is a fixed-precision type.

- Tom
sum | 1000|cash_pl |- | -| 790| 790| 0| 790| |
max | 1000|cashlarger |- | -| 790| 790| 0| 790| |
min | 1000|cashsmaller|- | -| 790| 790| 0| 790| |
(4 rows)

Should be fixed for 6.2.1...

Vadim

------------------------------------------------------------------------

Subject: Re: [QUESTIONS] Me again. avg problem
Date: Tue, 14 Oct 1997 11:20:52 +0300
From: Constantin Teodorescu <teo@flex.ro>
Organization: FLEX Consulting
To: Dustin Sallings <dustin@spy.net>
CC: PostgreSQL Questions <pgsql-questions@postgreSQL.org>
References: <ML-3.3-SPY.876814655.5758.dustin@bleu.west.spy.net>

Dustin Sallings wrote:
Hi, it's me again. :) Does this look funny to anyone?:
It is true. But only on money type fields

contabil=> create table test(price money,weight float8);
CREATE
contabil=> insert into test values(5,5);
INSERT 83448 1
contabil=> insert into test values(15,15);
INSERT 83449 1
contabil=> select avg(price),avg(weight) from test;
avg |avg
------+---
$20.00| 10
(1 row)

--

Constantin Teodorescu
FLEX Consulting Braila, ROMANIA
------------------------------

Search Discussions

  • Bruce Momjian at Oct 14, 1997 at 5:34 pm
    When you make the change, can you also put a file in the /migration
    directory, so people can make this fix without a full reinstall, and
    update the INSTALL file to mention this?

    Thanks.
    Vadim B. Mikheev wrote:
    (790 is OID of money)

    vac=> select * from pg_aggregate where aggbasetype = 790;
    aggname|aggowner|aggtransfn1|aggtransfn2|aggfinalfn|aggbasetype|aggtranstype1|aggtranstype2|aggfinaltype|agginitval1|agginitval2
    -------+--------+-----------+-----------+----------+-----------+-------------+-------------+------------+-----------+-----------
    avg | 1000|cash_pl |float8inc | -| 790| 790| 701| 790| | 0.0
    ^^^^^^^^^
    float8div ????
    No, the increment is OK. aggfinalfn needs to set to be a function which divides cash by float and returns cash. Could probably
    substitute integers for the floats without ill effect since cash is a fixed-precision type.

    - Tom
    sum | 1000|cash_pl |- | -| 790| 790| 0| 790| |
    max | 1000|cashlarger |- | -| 790| 790| 0| 790| |
    min | 1000|cashsmaller|- | -| 790| 790| 0| 790| |
    (4 rows)

    Should be fixed for 6.2.1...

    Vadim

    ------------------------------------------------------------------------

    Subject: Re: [QUESTIONS] Me again. avg problem
    Date: Tue, 14 Oct 1997 11:20:52 +0300
    From: Constantin Teodorescu <teo@flex.ro>
    Organization: FLEX Consulting
    To: Dustin Sallings <dustin@spy.net>
    CC: PostgreSQL Questions <pgsql-questions@postgreSQL.org>
    References: <ML-3.3-SPY.876814655.5758.dustin@bleu.west.spy.net>

    Dustin Sallings wrote:
    Hi, it's me again. :) Does this look funny to anyone?:
    It is true. But only on money type fields

    contabil=> create table test(price money,weight float8);
    CREATE
    contabil=> insert into test values(5,5);
    INSERT 83448 1
    contabil=> insert into test values(15,15);
    INSERT 83449 1
    contabil=> select avg(price),avg(weight) from test;
    avg |avg
    ------+---
    $20.00| 10
    (1 row)

    --

    Constantin Teodorescu
    FLEX Consulting Braila, ROMANIA



    - --
    Bruce Momjian
    maillist@candle.pha.pa.us

    ------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedOct 14, '97 at 1:50p
activeOct 14, '97 at 5:34p
posts2
users2
websitepostgresql.org...
irc#postgresql

People

Translate

site design / logo © 2021 Grokbase