[
https://issues.apache.org/jira/browse/DERBY-4371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12900304#action_12900304
]
C.S. Nirmal J. Fernando commented on DERBY-4371:
------------------------------------------------
Hi Lily,
Thanks for the reply.
I got confused with Knut's last post
i.e. select distinct i*j from t1 order by i/j
This statement should be rejected because none of the columns I or J, or the
expression I/J are contained directly in the select list (both I and J are in
an expression in the select list, but not on the top level, so there's no
functional dependency between the columns in the select list and the expression
in the order by clause).
What you think? Isn't this implies as it's enough to have I OR J? May be Knut
accidentally mistyped it.
Thanks.
> Non-selected columns for SELECT DISTINCT allowed in ORDER BY clause if
> ordered by expression
> --------------------------------------------------------------------------------------------
>
> Key: DERBY-4371
> URL: https://issues.apache.org/jira/browse/DERBY-4371
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.5.1.1
> Reporter: Bernt M. Johnsen
> Assignee: C.S. Nirmal J. Fernando
> Priority: Critical
> Attachments: DERBY-4371-2.diff, DERBY-4371-3.diff, DERBY-4371-4.diff,
> DERBY-4371.diff
>
>
> How to repeat:
> ij> create table t (i integer, j integer);;
> 0 rows inserted/updated/deleted
> ij> insert into t values (1,2),(1,3);
> 2 rows inserted/updated/deleted
> ij> select distinct i from t order by j;
> ERROR 42879: The ORDER BY clause may not contain column 'J', since the query
> specifies DISTINCT and that column does not appear in the query result.
> ij> select distinct i from t order by j*2;
> I
> -----------
> 1
> 1
> 2 rows selected
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.