Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 24124 invoked from network); 19 Feb 2008 02:43:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Feb 2008 02:43:06 -0000 Received: (qmail 44957 invoked by uid 500); 19 Feb 2008 02:43:00 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 44913 invoked by uid 500); 19 Feb 2008 02:43:00 -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 44903 invoked by uid 99); 19 Feb 2008 02:43:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 18 Feb 2008 18:43:00 -0800 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; Tue, 19 Feb 2008 02:42:35 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 575BD234C042 for ; Mon, 18 Feb 2008 18:42:35 -0800 (PST) Message-ID: <465352090.1203388955356.JavaMail.jira@brutus> Date: Mon, 18 Feb 2008 18:42:35 -0800 (PST) From: "Bryan Pendleton (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-2351) ORDER BY with expression with distinct in the select list returns incorrect result In-Reply-To: <5230524.1171672685493.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/DERBY-2351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12570083#action_12570083 ] Bryan Pendleton commented on DERBY-2351: ---------------------------------------- Here's an interesting example of a query combining both expressions and column aliases in the ORDER BY clause: create table t1 (a varchar(10)); insert into t1 values ('M'), ('k'), ('c'), ('K'), ('m'); SELECT CONCAT('test', a) AS str FROM t1 ORDER BY UPPER(str); > ORDER BY with expression with distinct in the select list returns incorrect result > ---------------------------------------------------------------------------------- > > Key: DERBY-2351 > URL: https://issues.apache.org/jira/browse/DERBY-2351 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.2.1.6, 10.2.2.0, 10.3.1.4 > Environment: Any > Reporter: Yip Ng > Assignee: Bryan Pendleton > Fix For: 10.3.2.1, 10.4.0.0 > > Attachments: derby_2351.diff, derby_2351_v2.diff, reproTests.diff > > > When distinct is in the select list and the query has order by with expression, the resultset produced contains an additional column. > ij> create table t1 (c1 int, c2 varchar(10)) > 0 rows inserted/updated/deleted > ij> insert into t1 values (1,'a'),(2,'b'),(3,'c'); > 3 rows inserted/updated/deleted > select distinct c1, c2 from t1 order by c1; > C1 |C2 > ---------------------- > 1 |a > 2 |b > 3 |c > 3 rows selected > ij> select distinct c1, c2 from t1 order by c1+1; > C1 |C2 |3 <=====returns 3 columns, incorrect result returned > ---------------------------------- > 1 |a |2 > 2 |b |3 > 3 |c |4 > 3 rows selected -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.