List:General Discussion« Previous MessageNext Message »
From:Richard Unger Date:September 17 2002 7:20pm
Subject:RE: aggregate functions producing bad data
View as plain text  
I _thought_ it was the fault of the aggregate function, but now I'm really confused!  When
I produce them as 3 separate queries, I still get numbers that don't add up:

mysql> select count(id) from t_calllog_calls;
+-----------+
| count(id) |
+-----------+
|      1994 |
+-----------+
1 row in set (0.00 sec)

mysql> select count(id) from t_calllog_calls where call_end - call_start > 5;
+-----------+
| count(id) |
+-----------+
|      1956 |
+-----------+
1 row in set (0.00 sec)

mysql> select count(id) from t_calllog_calls where call_end - call_start <= 5;
+-----------+
| count(id) |
+-----------+
|        35 |
+-----------+

-----Original Message-----
From: Richard Unger 
Sent: Tuesday, September 17, 2002 12:00 PM
To: 'mysql@stripped'
Subject: aggregate functions producing bad data


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

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