[MDEV-9437] COUNT DISTINCE with GROUP BY with ORDER BY broken Created: 2016-01-20  Updated: 2016-02-17  Resolved: 2016-02-17

Status: Closed
Project: MariaDB Server
Component/s: OTHER
Affects Version/s: 10.0.22
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: M. Braun Assignee: Unassigned
Resolution: Incomplete Votes: 0
Labels: need_feedback


 Description   

I'm running two queries on a view. Both group by the same set of columns (a,b,c) and count the values of a fourth column d. When using COUNT(d), the query returns 13 rows. When using COUNT(Dinstinct d), the queries returns >30 rows, most of them have count(d)=1. Obviously, the latter output is wrong.

Using distinct works when skipping the ORDER BY clause or using the same column ordering in the order by clause as with the group by clause.

Works:

SELECT a,b,c , count( d ) FROM someView
GROUP BY a,b,c
ORDER BY c,a,b
LIMIT 0,30

Works:

SELECT a,b,c , count(distinct d ) FROM someView
GROUP BY a,b,c
ORDER BY a,b,c
LIMIT 0,30

Broken:

SELECT a,b,c , count(distinct d ) FROM someView
GROUP BY a,b,c
ORDER BY c,a,b
LIMIT 0,30

I'm using MariaDB 10.0.22-MariaDB-0+deb8u1 - (Debian). This used to work with MySQL 5 and maybe MariaDB 5.



 Comments   
Comment by Elena Stepanova [ 2016-01-20 ]

If possible, please provide the schema/data dump.
If you can't do that, please paste the output of SHOW CREATE VIEW <someView> and for all tables it uses, SHOW CREATE TABLE and SHOW INDEX IN.
Please also attach your cnf file(s).

Comment by Elena Stepanova [ 2016-02-17 ]

Please comment to re-open if you have more information on the issue.

Generated at Thu Feb 08 07:34:40 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.