Thread

  1. select avg() and sum() returns false value

    PostgreSQL Bugs List <pgsql-bugs@postgresql.org> — 2001-05-18T22:03:42Z

    Christoph Lorenz (Christoph_Lorenz@gmx.de) reports a bug with a severity of 2
    The lower the number the more severe it is.
    
    Short Description
    select avg() and sum() returns false value
    
    Long Description
    I don't know, if it's my fault, but when I sum up several thousands
    of positive entries in a column (the column is an int2 field), I get a negative(!) value.
    
    Sample Code
    CREATE TABLE recording (
      [...]
      time int2 DEFAULT NULL,
      [...]
    );
    
    
    
    select time from recording returns only positive values, like time 
    ------
      277
      159
      192
      183
      184
      178
      180
      207
      243
      194
      203
      182
      277
      159
      192
      183
      184
      178
      180
      207
      243
      194
      203
      182
      229
      229
    
    
    and when I sum it up, the following happens (remember, there are really no negative values in my database):
    
    mmusic2=# select sum(time) from recording;
      sum   
    --------
     -12491
    (1 row)
    
    
    
    No file was uploaded with this report
    
    
    
  2. Re: select avg() and sum() returns false value

    Tom Lane <tgl@sss.pgh.pa.us> — 2001-05-18T22:18:31Z

    pgsql-bugs@postgresql.org writes:
    > I don't know, if it's my fault, but when I sum up several thousands
    > of positive entries in a column (the column is an int2 field), I get a negative(!) value.
    
    Use Postgres 7.1.
    
    			regards, tom lane