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