Thanks, Satheesh!

Satheesh Bandaram (JIRA) wrote:

[ http://issues.apache.org/jira/browse/DERBY-280?page=comments#action_12357918 ]
Satheesh Bandaram commented on DERBY-280:
-----------------------------------------

I have submitted this fix to trunk. Please Resolve and Close the bug after 
confirming the fix.

I have added a comment to indicate this problem is caused by current parser 
rewrite and that any fix to address Derby-681 would make this problem go away. 
Rick, I hope you don't mind this comment:

        ** This issue is caused by parser rewriting of group by/having clauses
        ** into table expressions. (See function tableExpression() in this file)
        ** There is an improvement request filed under DERBY-681 to eliminate 
this
        ** rewrite, after which it should be possible to allow multiple columns 
to
        ** have same name in the select list.

Sending        java\engine\org\apache\derby\iapi\reference\SQLState.java
Sending        java\engine\org\apache\derby\impl\sql\compile\sqlgrammar.jj
Sending        java\engine\org\apache\derby\loc\messages_en.properties
Sending        
java\testing\org\apache\derbyTesting\functionTests\master\aggregate.out
Sending        
java\testing\org\apache\derbyTesting\functionTests\tests\lang\aggregate.sql
Transmitting file data .....
Committed revision 345304.

Wrong result from select when aliasing to same name as used in group by
-----------------------------------------------------------------------

        Key: DERBY-280
        URL: http://issues.apache.org/jira/browse/DERBY-280
    Project: Derby
       Type: Bug
 Components: SQL
   Reporter: Bernt M. Johnsen
   Assignee: Rick Hillegas
   Priority: Minor
Attachments: bug280.diff

Wrong result from select when aliasing to same name as used in group by. 
Example:
If we have the following table:
   ij> select * from tt;
   I          |J
   -----------------------
   1          |2
   2          |3
   1          |2
   2          |3
   2          |3
5 rows selected
The following select is ok:
   ij> select i, count(*) as cnt from tt group by i;
   I          |CNT
   -----------------------
   1          |2
   2          |3
2 rows selected
But this one returns wrong result in the aliased column:
   ij> select i, count(*) as i from tt group by i;
   I          |I
   -----------------------
   1          |1
   2          |2
2 rows selected


Reply via email to