Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 47910 invoked from network); 28 Sep 2009 23:45:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Sep 2009 23:45:46 -0000 Received: (qmail 33371 invoked by uid 500); 28 Sep 2009 23:45:46 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 33341 invoked by uid 500); 28 Sep 2009 23:45:46 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 33333 invoked by uid 99); 28 Sep 2009 23:45:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Sep 2009 23:45:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Sep 2009 23:45:36 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 0B566234C004 for ; Mon, 28 Sep 2009 16:45:16 -0700 (PDT) Message-ID: <734845966.1254181516032.JavaMail.jira@brutus> Date: Mon, 28 Sep 2009 16:45:16 -0700 (PDT) From: "Bryan Pendleton (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-3634) Cannot use row_number() in ORDER BY clause In-Reply-To: <1747973222.1208544261642.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-3634?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12760440#action_12760440 ] Bryan Pendleton commented on DERBY-3634: ---------------------------------------- Hi Micky, Currently, the patch only applies to the trunk. You can use the trunk code with your current 10.5 database as follows: 1) Make a backup of your 10.5 database and restore it to a testing location (IMPORTANT!) 2) When you run the modified, patched, trunk software to access your test copy of your database, pass -Dderby.database.allowPreReleaseUpgrade=true This special flag tells the Derby software that it's OK to open your database using the unreleased trunk code, and it will automatically be upgraded to 10.6 trunk format. This automatic upgrade, which cannot be undone, is why it is CRITICAL that you do this with a testing copy of your database, NOT with your production data. If these instructions are confusing, please let us know and I can try to explain some more. > Cannot use row_number() in ORDER BY clause > ------------------------------------------ > > Key: DERBY-3634 > URL: https://issues.apache.org/jira/browse/DERBY-3634 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.4.1.3 > Reporter: Rick Hillegas > Assignee: Dag H. Wanvik > Attachments: derby-3634-a.diff, derby-3634-a.stat, derby-3634-a.txt, derby-3634-b.diff, derby-3634-b.stat, derby-3634-remove.diff, derby-3634-remove.stat > > > The following query works correctly: > select abs(a), row_number() over () > from t > where a > 100 and a < 111 > order by abs(a) > I expected the following query to also work, but it raised an exception: > select abs(a), row_number() over () > from t > where a > 100 and a < 111 > order by row_number() over () > This is the error I saw: "ERROR 42X01: Syntax error: Encountered "over" at line 5, column 23". > Here are the reasons why I think that this syntax is supposed to be supported: > According to my reading of the 2003 SQL spec, the ORDER BY clause should be able to sort on any expression in the SELECT list. That includes OLAP expressions. I believe this is so because, according to part 2, section 10.10 (), a can be any and if you follow the grammar for , it can resolve to be a (see section 6.3), which can in turn resolve to be a . This reasoning is supported by tracing the hotlinks on the following page which lays out the SQL 2003 BNF: http://savage.net.au/SQL/sql-2003-2.bnf.html This interpretation is further supported by the example of an ORDER BY clause referencing an OLAP expression which is provided on page 23 of the introduction to OLAP written by Fred Zemke, Krishna Kulkarni, Andy Witkowski, and Bob Lyle: www.cse.iitb.ac.in/dbms/Data/Papers-Other/SQL1999/OLAP-99-154r2.pdf -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.