Issue Details (XML | Word | Printable)

Key: DERBY-3231
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Manish Khettry
Reporter: Peter Balon
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Sorting on COUNT with OR and GROUP BY delivers wrong results.

Created: 27/Nov/07 10:16 AM   Updated: 30/Jun/09 03:55 PM
Return to search
Component/s: SQL
Affects Version/s: 10.3.1.4
Fix Version/s: 10.3.3.0, 10.4.1.3

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works d3231_v2.patch 2007-12-13 04:57 PM A B 2 kB
Text File Licensed for inclusion in ASF works order_by_bug.diff.txt 2007-12-11 02:14 AM Manish Khettry 2 kB
Environment: Eclipse 3.2.2; java 1.5.0_11;
Issue Links:
Incorporates
 
Reference
 

Urgency: Urgent
Bug behavior facts: Regression
Resolution Date: 24/Jan/08 09:59 PM


 Description  « Hide
The result of the select is not sorted in "order by COUNT(*) DESC" or "order by COUNT(*) ASC"

create table yy (a double, b double);

insert into yy values (2, 4);
insert into yy values (5, 7);
insert into yy values (2, 3);
insert into yy values (2, 3);
insert into yy values (2, 3);
insert into yy values (2, 3);
insert into yy values (9, 7);


select b, COUNT(*) AS "COUNT_OF", SUM(b) AS "sum b"
from yy
where a = 5 or a = 2
group by b
order by COUNT(*) asc

-- same result as:

select b, COUNT(*) AS "COUNT_OF", SUM(b) AS "sum b"
from yy
where a = 5 or a = 2
group by b
order by COUNT(*) desc


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #603954 Thu Dec 13 16:54:39 UTC 2007 abrown DERBY-3231: Sorting on COUNT with OR and GROUP BY delivers wrong results.
Patch contributed by: Manish Khettry.
Files Changed
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java

Repository Revision Date User Message
ASF #615042 Thu Jan 24 21:57:41 UTC 2008 kmarsden DERBY-3231 Sorting on COUNT with OR and GROUP BY delivers wrong results.
port revision 603954 from trunk.
Fix contributed by Manish Khettry.
Files Changed
MODIFY /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/compile/AggregateNode.java
MODIFY /db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GroupByTest.java