You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Bernt M. Johnsen" <Be...@Sun.COM> on 2005/05/12 10:53:53 UTC

Strange behaviour when combining column alias and group by

I stumbeled across this strange behaviour when combining coumn alias
and group by:

ij> select * from tt;
I          |J          
-----------------------
1          |2          
2          |3          
1          |2          
2          |3          
2          |3          

5 rows selected
ij> select i, count(*) as cnt from tt group by i;
I          |CNT        
-----------------------
1          |2          
2          |3          

2 rows selected
ij> select i, count(*) as i from tt group by i;
I          |I          
-----------------------
1          |1          
2          |2          

2 rows selected

The last select is obviously wrong! This might be related to
DERBY-127, but if it's not I'll file it asa separate issue.


-- 
Bernt Marius Johnsen, Database Technology Group, 
Sun Microsystems, Trondheim, Norway

Re: Strange behaviour when combining column alias and group by

Posted by Satheesh Bandaram <sa...@Sourcery.Org>.
Well, fix for Derby-127 doesn't fix this. Looks like we need a new Jira
entry. Exposed name handling is getting better, but looks like still has
some kinks.

Satheesh

Bernt M. Johnsen wrote:

>I stumbeled across this strange behaviour when combining coumn alias
>and group by:
>
>ij> select * from tt;
>I          |J          
>-----------------------
>1          |2          
>2          |3          
>1          |2          
>2          |3          
>2          |3          
>
>5 rows selected
>ij> select i, count(*) as cnt from tt group by i;
>I          |CNT        
>-----------------------
>1          |2          
>2          |3          
>
>2 rows selected
>ij> select i, count(*) as i from tt group by i;
>I          |I          
>-----------------------
>1          |1          
>2          |2          
>
>2 rows selected
>
>The last select is obviously wrong! This might be related to
>DERBY-127, but if it's not I'll file it asa separate issue.
>
>
>  
>


Re: Strange behaviour when combining column alias and group by

Posted by Jack Klebanoff <kl...@sbcglobal.net>.
Bernt M. Johnsen wrote:

>I stumbeled across this strange behaviour when combining coumn alias
>and group by:
>
>ij> select * from tt;
>I          |J          
>-----------------------
>1          |2          
>2          |3          
>1          |2          
>2          |3          
>2          |3          
>
>5 rows selected
>ij> select i, count(*) as cnt from tt group by i;
>I          |CNT        
>-----------------------
>1          |2          
>2          |3          
>
>2 rows selected
>ij> select i, count(*) as i from tt group by i;
>I          |I          
>-----------------------
>1          |1          
>2          |2          
>
>2 rows selected
>
>The last select is obviously wrong! This might be related to
>DERBY-127, but if it's not I'll file it asa separate issue.
>
>
>  
>
I think that this is a different issue than Derby-127. Derby-127 
concerned the combination of group by with order by. The two are 
probably related. Please file a separate Jira-report for this one.

Jack Klebanoff