Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0EA309514 for ; Wed, 15 Feb 2012 14:49:26 +0000 (UTC) Received: (qmail 61106 invoked by uid 500); 15 Feb 2012 14:49:25 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 61074 invoked by uid 500); 15 Feb 2012 14:49:25 -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 61066 invoked by uid 99); 15 Feb 2012 14:49:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Feb 2012 14:49:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Feb 2012 14:49:20 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 81AF11B9994 for ; Wed, 15 Feb 2012 14:48:59 +0000 (UTC) Date: Wed, 15 Feb 2012 14:48:59 +0000 (UTC) From: "Bryan Pendleton (Commented) (JIRA)" To: derby-dev@db.apache.org Message-ID: <32607133.40805.1329317339532.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <291642869.33395.1329166619543.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (DERBY-5613) Queries with group by column not included in the column list for JOIN(INNER or OUTER) with NATURAL or USING does not fail 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-5613?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13208512#comment-13208512 ] Bryan Pendleton commented on DERBY-5613: ---------------------------------------- If it's an inner join, aren't countries.country and cities.country equivalent? Is this issue only for outer joins (left or right)? I agree that we need to obey the sql spec's description of how the query should behave. I'm not terribly familiar with USING syntax; is there a semantic difference between SELECT country,count(country) FROM COUNTRIES JOIN CITIES USING (COUNTRY) group by country and SELECT country,count(country) FROM COUNTRIES, cities where countries.country = cities.country group by country > Queries with group by column not included in the column list for JOIN(INNER or OUTER) with NATURAL or USING does not fail > ------------------------------------------------------------------------------------------------------------------------- > > Key: DERBY-5613 > URL: https://issues.apache.org/jira/browse/DERBY-5613 > Project: Derby > Issue Type: Bug > Components: SQL > Affects Versions: 10.8.2.2 > Reporter: Mamta A. Satoor > > A query like following does not raise an error even though countries.country is not part of the SELECT column list. > SELECT country,count(country) FROM > COUNTRIES JOIN CITIES USING (COUNTRY) group by countries.country > This jira is related to DERBY-4631. As noted by Knut in DERBY-4631, SQL:2003 says that the join columns in a natural join or in a named columns join should be added to the select list by coalescing the column from the left table with the column from the right table. > Section 7.7, , syntax rules: > > 1) Let TR1 be the first , and let TR2 be the
> reference> or
that is the second operand of the > > . Let RT1 and RT2 be the row types of TR1 and TR2, > > respectively. Let TA and TB be the range variables of TR1 and TR2, > > respectively. (...) > and > > 7) If NATURAL is specified or if a immediately > > containing a is specified, then: > (...) > > d) If there is at least one corresponding join column, then let SLCC > > be a