[ 
http://issues.apache.org/jira/browse/DERBY-883?page=comments#action_12402467 ] 

Manish Khettry commented on DERBY-883:
--------------------------------------

I have a few questions on this, largely functional.

1. In terms of syntax, do we allow expressions in the group by list or 
positional parameters, or both?

select tomonth(creationdt), toyear(creationdt), count(*)
from bugs
group by 1, 2; 

or 
group by tomonth(creationdt), toyear(creationdt);

An implementation question on this note-- does the language code have a way of 
looking at two expressions (ValueNode?) and checking to see if they are 
equivalent? We'll need some way of doing this to match an expression in the 
group by list to an expression in the select list right?

2. I assume that an expression in a group by list must appear in the select 
list without aggregation right? Is this an error?

select x+1, x+2, sum(y)
from test
group by x
;

3. What do we do with duplicates? i.e.

select x+1, x+1, sum(y)
from test
group by x+1, x+1;

Is this an error? The current implementation throws an error if the same column 
occurs more than once in the group by list.

Is there a standard somewhere which I should consult before trying to nail down 
the functionality?


> Enhance GROUP BY clause to support expressions instead of just column 
> references.
> ---------------------------------------------------------------------------------
>
>          Key: DERBY-883
>          URL: http://issues.apache.org/jira/browse/DERBY-883
>      Project: Derby
>         Type: New Feature

>   Components: SQL
>     Versions: 10.1.2.1
>  Environment: JDK 1.5.0_05
>     Reporter: Lluis Turro
>     Assignee: Manish Khettry

>
> This select would return an error syntax on finding "(" after month if group 
> by clause:
> select idissue, month(creation), year(creation), count(distinct idissue)
> where 
>   ....
> group by idissue, month(creation), year(creation)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to