List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 12 2000 5:22pm
Subject:Re: big problem with COUNT()
View as plain text  
At 6:15 PM +0100 01-12-2000, Jan Dvorak wrote:
>Paul DuBois wrote:
>>
>>  At 4:37 PM +0100 2000-01-07, Nicolas Prade wrote:
>>  >Hello,
>>  >using a COUNT(...) in an arithmetic operation
>>  >is sometimes very problematic.
>>  >
>>  >Could someone please try this simple test procedure :
>>  >
>>  >  >CREATE TABLE test (d DATETIME, i INT);
>>  >  >INSERT INTO test VALUES (NOW(), 1);
>>  >
>>  >  >SELECT COUNT(i), i, COUNT(i)*i FROM test GROUP BY i;
>>  >+----------+------+------------+
>>  >| COUNT(i) | i    | COUNT(i)*i |
>>  >+----------+------+------------+
>>  >|        1 |    1 |          1 |
>>  >+----------+------+------------+
>>  >
>>  >  >SELECT COUNT(i), (i+0), COUNT(i)*(i+0) FROM test GROUP BY i;
>>  >+----------+-------+----------------+
>>  >| COUNT(i) | (i+0) | COUNT(i)*(i+0) |
>>  >+----------+-------+----------------+
>>  >|        1 |     1 |              0 |
>>  >+----------+-------+----------------+
>>  >
>>  >Nobody here can explain this.
>
>I'm not sure how much sense
>it makes to say COUNT(i) when you GROUP BY i.
>Shouldn't one say COUNT(*) instead?


Do you have some specific objection, or have you simply not
tried it?

-- 
Paul DuBois, paul@stripped
Thread
big problem with COUNT()Nicolas Prade7 Jan
  • Re: big problem with COUNT()Paul DuBois7 Jan
    • Re: big problem with COUNT()Michael Widenius26 Jan
  • Re: big problem with COUNT()Jan Dvorak12 Jan
    • Re: big problem with COUNT()Paul DuBois12 Jan
    • RE: big problem with COUNT()Nicolas Prade12 Jan
  • Re: big problem with COUNT()Steve Ruby12 Jan
  • Re: big problem with COUNT()Steve Ruby12 Jan