Re: [GENERAL] sum() bug?

From: Ed Loehr <eloehr(at)austin(dot)rr(dot)com>
To: Vincent Bodenstab <vincent(dot)bodenstab(at)quicknet(dot)nl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] sum() bug?
Date: 2000-03-06 20:39:54
Message-ID: 38C4179A.783FFB70@austin.rr.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vincent Bodenstab wrote:
>
> Hi all,
>
> I was just wondering: when I execute the following query:
>
> select sum(foo) from bar where column1='value_which_does_not_exist';
>
> postgres gives me a result which consists of one row. But it shouldn't
> because
> that value does not exist.
>
> Does anyone know some sort of workaround for this? I need to use this
> query in
> a PHP script and this result in kind off annoying.

Yes, a bit annoying. I think this may be fixed in 7.0 (as part of
similar group by problem?), but my 6.5.* workaround (in perl+DBI) is
to check for an undefined value, i.e.,

while ( $result_row = fetch... ) {
next if ( ! defined($result_row->{'sum'}) );
...
process real results...
}

Regards,
Ed Loehr

In response to

  • sum() bug? at 2000-03-06 17:23:21 from Vincent Bodenstab

Browse pgsql-general by date

  From Date Subject
Next Message Ron Chmara 2000-03-06 20:52:20 Re: [GENERAL] DHCP and pg_hba.conf
Previous Message Alfred Perlstein 2000-03-06 20:29:49 Re: [GENERAL] DHCP and pg_hba.conf