Actually, Jay, I've bumped into cases where you couldn't avoid a nested
query.  Here's an example that works in SQLite:

SELECT COUNT(funky_values) 
FROM (SELECT substr(locations.code, 5,9) AS funky_values FROM locations
WHERE locations.code LIKE 'B%')
WHERE funky_values LIKE '1%'
;

I think the problem in Yannick's query was the attempt to alias a table
name.  In the above, I alias the field name in the sub query and reference
it without a table name.

jaime

-----Original Message-----
From: Jay Sprenkle [mailto:[EMAIL PROTECTED] 
Sent: Sunday, April 08, 2007 2:15 PM
To: [email protected]
Subject: Re: [sqlite] Nested SELECT : Alternative syntax please ?

Access isn't very compatible with anything else ;)
why is the outer select wrapped around the inner query?
why not just put the group by on the inner query?

  SELECT SUM(SomeField)
  FROM complex query tables here
  GROUP BY SomeOtherField



On 4/8/07, Yannick Létourneau <[EMAIL PROTECTED]> wrote:
>
> I used to do this kind of SELECT statement in MS Access.  This syntax
> doesn't seem to be understood by SQLite.  Can someone help me find the
> SQLite syntax for doing this ?
>
>   SELECT SUM(IntermediateQuery.SomeField)
>   FROM (some complex nested SELECT query) AS IntermediateQuery
>   GROUP BY IntermediateQuery.SomeOtherField
>
>   SQLite complains there is no such field as IntermediateQuery.SomeField..
> .
>
>   Any help ?
>   Emp
>



-- 
--
The PixAddixImage Collector suite:
http://groups-beta.google.com/group/pixaddix

SqliteImporter and SqliteReplicator: Command line utilities for Sqlite
http://www.reddawn.net/~jsprenkl/Sqlite

Cthulhu Bucks!
http://www.cthulhubucks.com



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to