Bug #48102 Documentation wrong about COUNT(DISTINCT) in 11.12.1
Submitted: 16 Oct 2009 0:16 Modified: 20 Oct 2009 20:00
Reporter: Filipus Klutiero Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.1 OS:Linux
Assigned to: Paul DuBois CPU Architecture:Any

[16 Oct 2009 0:16] Filipus Klutiero
Description:
According to http://dev.mysql.com/doc/refman/5.1/en/group-by-functions.html#function_count-distinct

COUNT(DISTINCT expr,[expr...])

Returns a count of the number of different non-NULL values.

This is obviously wrong. Like COUNT(), COUNT(DISTINCT) returns a number of rows.

How to repeat:
CREATE TABLE `mysql_bug` (
`whatever` INT NOT NULL ,
`whichever` INT NOT NULL
) ENGINE = MYISAM ;
INSERT INTO`mysql_bug` (`whatever`, `whichever`) VALUES ('1', '2');
SELECT COUNT( DISTINCT `whatever` , `whichever` )
FROM `mysql_bug`

COUNT(DISTINCT `whatever`, `whichever`)
1

Suggested fix:
Returns a count of the number of different rows without any non-NULL values.
[16 Oct 2009 0:21] MySQL Verification Team
Thank you for the bug report.
[20 Oct 2009 20:00] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.