[ 
https://issues.apache.org/jira/browse/DERBY-4397?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12763309#action_12763309
 ] 

Dag H. Wanvik commented on DERBY-4397:
--------------------------------------

Thanks for looking at this, Knut, Rick.
@Knut
Re 1), I can't see that ORDER BY should be allowed before a UNION without a (), 
can you explain how you reach that conclusion? It seems to me that what comes 
before the UNION must eventually come from a <query primary> which is either a 
table name or a (parenthesized)  subquery..

2) I hope  so, I agree that in an INSERT context, an ORDER BY in the subquery 
should not be ignored in the presence of identity columns.
3) Yes that is correct, I was thinking of the case where the ORDER BY is inside 
a subquery and the containing query contains a window. Btw, hat case may be 
covered by an ORDER BY inside the window specification (equivalently?) when we 
support that.
4) I am not aware of any such backwards-compatibility issues at this point. I 
added this as a reminder to self to check it ;-)

@Rick
Good point about the user guide for INSERT. Will add a note on that.


> Allow ORDER BY in subqueries
> ----------------------------
>
>                 Key: DERBY-4397
>                 URL: https://issues.apache.org/jira/browse/DERBY-4397
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>            Reporter: Dag H. Wanvik
>         Attachments: orderBySpec.html
>
>
> SQL 2008 allows ORDER BY to be specified in subqueries. In conjunction with 
> OFFSET/FETCH and/or ROW_NUMBER
> meaningful subqueries with row ordering may be formulated. Cf. MySQL's LIMIT 
> may be used in subqueries as well.
> Note that OFFSET/FETCH is currently not allowed in subqueries, either.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to