Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 59452 invoked from network); 10 Apr 2008 04:58:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Apr 2008 04:58:53 -0000 Received: (qmail 19313 invoked by uid 500); 10 Apr 2008 04:58:53 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 19285 invoked by uid 500); 10 Apr 2008 04:58:53 -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 19276 invoked by uid 99); 10 Apr 2008 04:58:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2008 21:58:53 -0700 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; Thu, 10 Apr 2008 04:58:19 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 09B17234C0C1 for ; Wed, 9 Apr 2008 21:56:05 -0700 (PDT) Message-ID: <1239995455.1207803365038.JavaMail.jira@brutus> Date: Wed, 9 Apr 2008 21:56:05 -0700 (PDT) From: "Bryan Pendleton (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-3593) ErrorCode 30000 when quering a select with 'having' clause and named tables with aliases for selected fields In-Reply-To: <517973056.1207264045036.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-3593?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12587490#action_12587490 ] Bryan Pendleton commented on DERBY-3593: ---------------------------------------- Can you provide a complete standalone script that we can run to see this? I'm having a bit of trouble reproducing the problem. Here's what I tried, and it worked for me (with the current trunk code): create table "values" (indicador_id int, valor int); insert into "values" values (1,1); select v.indicador_id as col_1, 'someString' as col_2, sum(v.valor) as col_3 from "values" v where v.valor is null and v.indicador_id = 13 group by v.indicador_id having sum(v.valor) > 3 ; COL_1 |COL_2 |COL_3 ---------------------------------- 0 rows selected > ErrorCode 30000 when quering a select with 'having' clause and named tables with aliases for selected fields > ------------------------------------------------------------------------------------------------------------ > > Key: DERBY-3593 > URL: https://issues.apache.org/jira/browse/DERBY-3593 > Project: Derby > Issue Type: Bug > Affects Versions: 10.2.2.1, 10.3.2.2 > Environment: WinVista 32bits, Running a java 1.4 application Aplication > Reporter: Bruno Medeiros > Priority: Critical > > When I run a query like this: > ------------------------------------------------------------------------- > select > v.indicador_id as col_1, > 'someString' as col_2, > sum(v.valor) as col_3 > from > VALUES v > where v.valor is null > and v.indicador_id = 13 > group by v.indicador_id > having sum(v.valor) > 3 > -------------------------------------------------------------------------- > I got a error: > Error: Column 'V.COL_1' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'V.COL_1' is not a column in the target table. > SQLState: 42X04 > ErrorCode: 30000 > ---------------------------------------------------------------------------- > if i gave no name to the table 'VALUES' or remove the aliases 'col_1' and 'col_3' of the corresponding selected fields, the query runs ok. The alias for the constant column, 'col_2', don't affect the query. > The query also runs ok if i remove the 'having' clause. > Queries that work: > ---------------------------------------------------------------------------- > select > v.indicador_id , > 'jujuba' as col_2, > sum(v.valor) > from > VALUES v > where v.valor is null > and v.indicador_id = 13 > group by v.indicador_id > having sum(v.valor) > 3 > ---------------------------------------------------------------------------- > select > indicador_id as col_1, > 'jujuba' as col_2, > sum(valor) as col_3 > from > VALUES > where valor is null > and indicador_id = 13 > group by indicador_id > having sum(valor) > 3 > ---------------------------------------------------------------------------- > select > v.indicador_id as col_1, > 'jujuba' as col_2, > sum(v.valor) as col_3 > from > VALUES v > where v.valor is null > and v.indicador_id = 13 > group by v.indicador_id > ---------------------------------------------------------------------------- > I think there's a problem when derby is trying to match the selected fields with the grouped ones, because 'V.COL_1', as it appears in the error message, doesn't exist in any place of my query. The correct would be 'V.indicador' or 'COL_1'. > Thanks in advance, > Bruno Medeiros -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.