Re: null answer - how?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: null answer - how?
Date: 2001-09-19 18:34:56
Message-ID: Pine.BSF.4.21.0109191130380.68729-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 19 Sep 2001, Patrick Welche wrote:

> select coalesce(sum(deltafromoctets),0)
> from trans,stats
> where stats_id=stats.id
> and (timeslicet < '1:05' OR timeslicet > '6:05')
>
> returns a number (9188191930), whereas
>
> select coalesce(sum(deltafromoctets),0)
> from trans,stats
> where stats_id=stats.id
> and (timeslicet < '1:05' OR timeslicet > '6:05')
> and timesliced < '01-May-2001'
>
> prints 0 (or null without the coalesce) as does
>
> select coalesce(sum(deltafromoctets),0)
> from trans,stats
> where stats_id=stats.id
> and timesliced < '01-May-2001'
>
> How can this be?
>
> select * from stats where timesliced is null or timeslicet is null
> select * from trans where deltafromoctets is null
>
> both retun 0 rows.

Are there no rows with timesliced<'01-May-2001'? I think in that
case sum() gives you one row with NULL.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martín Marqués 2001-09-19 18:46:13 Re: Error in compiling PHP with PostgreSQL support
Previous Message Tom Lane 2001-09-19 18:06:08 Re: Messages