List:General Discussion« Previous MessageNext Message »
From:Richard Unger Date:September 17 2002 7:37pm
Subject:RE: aggregate functions producing bad data
View as plain text  
> -----Original Message-----
> From: Dan Nelson [mailto:dnelson@stripped]
> Sent: Tuesday, September 17, 2002 12:31 PM
> To: Brian Reichert
> Cc: Richard Unger; mysql@stripped
> Subject: Re: aggregate functions producing bad data
> 
> 
> In the last episode (Sep 17), Brian Reichert said:
> > On Tue, Sep 17, 2002 at 11:59:42AM -0700, Richard Unger wrote:
> > > My query:
> > > 
> > > SELECT 
> > > 	count(id), 
> > > 	count( IF(call_end - call_start > 5, id, NULL) ), 
> > > 	count( IF(call_end - call_start <= 5, id, NULL) )
> > > FROM 
> > > 	t_calllog_calls;
> > > 
> > > My result:
> > > 
> > > 1994
> > > 1956
> > > 35
> > > 
> > > However, 1956 + 35 != 1994.
> > > 
> > > Running MySQL 3.23.49-nt
> > 
> > One thing I'd check:  what happens if t_calllog_calls.id is NULL?
> 
> Also check if call_end or call_start are NULL; that will 
> cause both IFs
> to fail.  Don't you love NULLs :)
>  

Ooh, good suggestion.  I hadn't thought of that!

...but no, none of the call_start or call_end fields are NULL.

Yeah, I love nulls :)

Cheers,
Rich
Thread
aggregate functions producing bad dataRichard Unger17 Sep
  • Re: aggregate functions producing bad dataBrian Reichert17 Sep
    • Re: aggregate functions producing bad dataDan Nelson17 Sep
  • Re: aggregate functions producing bad dataGelu Gogancea17 Sep
  • Re: aggregate functions producing bad dataGelu Gogancea17 Sep
    • Re: aggregate functions producing bad datamtoth18 Sep
  • Re: aggregate functions producing bad dataGelu Gogancea17 Sep
RE: aggregate functions producing bad dataRichard Unger17 Sep
RE: aggregate functions producing bad dataRichard Unger17 Sep
  • RE: aggregate functions producing bad datamtoth17 Sep
RE: aggregate functions producing bad dataRichard Unger17 Sep
  • Re: aggregate functions producing bad dataJay17 Sep
    • re: Re: aggregate functions producing bad dataVictoria Reznichenko18 Sep
RE: aggregate functions producing bad dataRichard Unger17 Sep
RE: aggregate functions producing bad dataRichard Unger17 Sep
  • Re: aggregate functions producing bad dataBenjamin Pflugmann18 Sep
RE: aggregate functions producing bad dataGerben Gieling18 Sep