Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 33738 invoked from network); 21 Jan 2011 18:57:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Jan 2011 18:57:57 -0000 Received: (qmail 8581 invoked by uid 500); 21 Jan 2011 18:57:57 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 8381 invoked by uid 500); 21 Jan 2011 18:57:55 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 8374 invoked by uid 99); 21 Jan 2011 18:57:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Jan 2011 18:57:54 +0000 X-ASF-Spam-Status: No, hits=-0.1 required=10.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [216.82.241.99] (HELO mail51.messagelabs.com) (216.82.241.99) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Jan 2011 18:57:48 +0000 X-VirusChecked: Checked X-Env-Sender: PBortnovskiy@Jefferies.com X-Msg-Ref: server-11.tower-51.messagelabs.com!1295636245!68899137!3 X-StarScan-Version: 6.2.9; banners=-,-,- X-Originating-IP: [169.196.176.23] Received: (qmail 896 invoked from network); 21 Jan 2011 18:57:25 -0000 Received: from jefsmtp11.jefferies.com (HELO JEFSMTP11.dmz.jefco.local) (169.196.176.23) by server-11.tower-51.messagelabs.com with RC4-SHA encrypted SMTP; 21 Jan 2011 18:57:25 -0000 In-Reply-To: References: To: "Derby Discussion" MIME-Version: 1.0 Subject: Re: Issue with COUNT function X-KeepSent: 09E2BCEA:B919711E-8525781F:00680BCD; type=4; name=$KeepSent X-Mailer: Lotus Notes Release 8.5.2 August 10, 2010 From: Pavel Bortnovskiy Message-ID: Date: Fri, 21 Jan 2011 13:57:17 -0500 X-MIMETrack: Serialize by Router on JefSMTP11/JEFCO(Release 8.5.2 HF324|December 06, 2010) at 01/21/2011 01:57:25 PM, Serialize complete at 01/21/2011 01:57:25 PM Content-Type: multipart/alternative; boundary="=_alternative 006821798525781F_=" This is a multipart message in MIME format. --=_alternative 006821798525781F_= Content-Type: text/plain; charset="US-ASCII" I'd like to chime in and say that we run such SELECT COUNT(*) queries all the time in Derby and have never encountered a problem. Don't think that "AS" aliasing is necessary. From: Chris Wilson To: Derby Discussion Date: 01/21/2011 01:07 PM Subject: Re: Issue with COUNT function Hi NBW, On Fri, 21 Jan 2011, NBW wrote: > SELECT COUNT(*) FROM (SELECT file.md5, instCollection.collectionId FROM > file, collection leafCollection, collection instCollection WHERE > (file.status=1 OR file.status=2) and file.collectionId = > leafCollection.collectionId AND leafCollection.instanceCollectionId = > instCollection.collectionId GROUP BY file.md5, instCollection.collectionId) > > That query under Oracle works fine. Under Derby I get the following error: > > [42X01][30000] Syntax error: Encountered "" at line 1, column 313. > > If I run the query without the SELECT COUNT(*) it will run fine in Derby > too, but I am trying to get the count :-) > > I feel like I must be missing something obvious here. I think that every sub-SELECT must have a table alias in Derby, so add "AS t" to the end of the query (after the closing parenthesis) and it might work :) Cheers, Chris. -- Aptivate | http://www.aptivate.org | Phone: +44 1223 760887 The Humanitarian Centre, Fenner's, Gresham Road, Cambridge CB1 2ES Aptivate is a not-for-profit company registered in England and Wales with company number 04980791. Jefferies archives and monitors outgoing and incoming e-mail. The contents of this email, including any attachments, are confidential to the ordinary user of the email address to which it was addressed. If you are not the addressee of this email you may not copy, forward, disclose or otherwise use it or any part of it in any form whatsoever. This email may be produced at the request of regulators or in connection with civil litigation. Jefferies accepts no liability for any errors or omissions arising as a result of transmission. Use by other than intended recipients is prohibited. In the United Kingdom, Jefferies operates as Jefferies International Limited; registered in England: no. 1978621; registered office: Vintners Place, 68 Upper Thames Street, London EC4V 3BJ. Jefferies International Limited is authorised and regulated by the Financial Services Authority. --=_alternative 006821798525781F_= Content-Type: text/html; charset="US-ASCII" I'd like to chime in and say that we run such SELECT COUNT(*) queries all the time in Derby and have never encountered a problem.
Don't think that "AS" aliasing is necessary.


From: Chris Wilson <chris@aptivate.org>
To: Derby Discussion <derby-user@db.apache.org>
Date: 01/21/2011 01:07 PM
Subject: Re: Issue with COUNT function





Hi NBW,

On Fri, 21 Jan 2011, NBW wrote:

> SELECT COUNT(*) FROM (SELECT file.md5, instCollection.collectionId FROM
> file, collection leafCollection, collection instCollection WHERE
> (file.status=1 OR file.status=2) and file.collectionId =
> leafCollection.collectionId AND leafCollection.instanceCollectionId =
> instCollection.collectionId GROUP BY file.md5, instCollection.collectionId)
>
> That query under Oracle works fine. Under Derby I get the following error:
>
> [42X01][30000] Syntax error: Encountered "<EOF>" at line 1, column 313.
>
> If I run the query without the SELECT COUNT(*) it will run fine in Derby
> too, but I am trying to get the count :-)
>
> I feel like I must be missing something obvious here. 

I think that every sub-SELECT must have a table alias in Derby, so add "AS
t" to the end of the query (after the closing parenthesis) and it might
work :)

Cheers, Chris.
--
Aptivate |
http://www.aptivate.org | Phone: +44 1223 760887
The Humanitarian Centre, Fenner's, Gresham Road, Cambridge CB1 2ES

Aptivate is a not-for-profit company registered in England and Wales
with company number 04980791.





Jefferies archives and monitors outgoing and incoming e-mail. The contents of this email, including any attachments, are confidential to the ordinary user of the email address to which it was addressed. If you are not the addressee of this email you may not copy, forward, disclose or otherwise use it or any part of it in any form whatsoever. This email may be produced at the request of regulators or in connection with civil litigation. Jefferies accepts no liability for any errors or omissions arising as a result of transmission. Use by other than intended recipients is prohibited. In the United Kingdom, Jefferies operates as Jefferies International Limited; registered in England: no. 1978621; registered office: Vintners Place, 68 Upper Thames Street, London EC4V 3BJ. Jefferies International Limited is authorised and regulated by the Financial Services Authority. --=_alternative 006821798525781F_=--