...or you can try :
 SELECT
 count(*),
 count( IF(call_end - call_start > 5, id, NULL) ),
 count( IF(call_end - call_start <= 5, id, NULL) )
 FROM
 t_calllog_calls;

Regards,

Gelu
_____________________________________________________
G.NET SOFTWARE COMPANY

Permanent e-mail address : [EMAIL PROTECTED]
                                          [EMAIL PROTECTED]
----- Original Message -----
From: "Brian Reichert" <[EMAIL PROTECTED]>
To: "Richard Unger" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, September 17, 2002 10:16 PM
Subject: Re: aggregate functions producing bad data


> 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?
>
> > Cheers,
> > Rich
>
> --
> Brian 'you Bastard' Reichert <[EMAIL PROTECTED]>
> 37 Crystal Ave. #303 Daytime number: (603) 434-6842
> Derry NH 03038-1713 USA Intel architecture: the left-hand path
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to