db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavel Bortnovskiy <PBortnovs...@Jefferies.com>
Subject Re: Issue with COUNT function
Date Fri, 21 Jan 2011 18:57:17 GMT
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.
Mime
View raw message