[sqlite] Nested SELECT : Alternative syntax please ?

2007-04-08 Thread L�tourneau
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

Re: [sqlite] Nested SELECT : Alternative syntax please ?

2007-04-08 Thread Jay Sprenkle
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:

RE: [sqlite] Nested SELECT : Alternative syntax please ?

2007-04-08 Thread Jaime Castells
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

Re: [sqlite] Nested SELECT : Alternative syntax please ?

2007-04-08 Thread Jay Sprenkle
On 4/8/07, Jaime Castells [EMAIL PROTECTED] wrote: Actually, Jay, I've bumped into cases where you couldn't avoid a nested query. Me too, but usually only in Access. 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

[sqlite] Re: Nested SELECT : Alternative syntax please ?

2007-04-08 Thread Igor Tandetnik
Jaime Castells [EMAIL PROTECTED] wrote: 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%')

RE: [sqlite] Nested SELECT : Alternative syntax please ?

2007-04-08 Thread Jaime Castells
Hmm, I think the only time you really can't avoid a nested query is when you want to do a grouping function on the result of a grouping function. Like count the number of customers who have more than a certain number of orders. Something like: SELECT COUNT(cust.id) FROM (SELECT cust.id,

Re: [sqlite] Nested SELECT : Alternative syntax please ?

2007-04-08 Thread L�tourneau
I tried that as well, doesn't work either. The thing is, my intermediate query is quite complex (involving UNION and GROUP BY) which requires me to do nesting. I don't want to dump the intermediate results in a dummy table either. Yannick L. Jay Sprenkle [EMAIL PROTECTED]

Re: [sqlite] Nested SELECT : Alternative syntax please ?

2007-04-08 Thread L�tourneau
Actually it seems I hadn't tried hard enough ;) I managed to make it work using the following syntax (Thanks to Jay) : SELECT SUM(SomeField) FROM (some complex nested SELECT query) GROUP BY SomeOtherField; However I need to explicitely name all the fields of my intermediate

Re: [sqlite] Nested SELECT : Alternative syntax please ?

2007-04-08 Thread Jay Sprenkle
glad you got it to work :) On 4/8/07, Yannick Létourneau [EMAIL PROTECTED] wrote: Actually it seems I hadn't tried hard enough ;) I managed to make it work using the following syntax (Thanks to Jay) : SELECT SUM(SomeField) FROM (some complex nested SELECT query) GROUP BY

[sqlite] FTS does not support REPLACE

2007-04-08 Thread Paul Quinn
Quite simply, both the FTS1 and FTS2 modules return an error on INSERT OR REPLACE when there is a conflict. The rowid is being supplied with the INSERT statement which is generating the conflict. Is this by design, a known issue, or a defect? I'm also having trouble with FTS inserts/deletes

[sqlite] Re: Nested SELECT : Alternative syntax please ?

2007-04-08 Thread Igor Tandetnik
Jaime Castells [EMAIL PROTECTED] wrote: Hmm, I think the only time you really can't avoid a nested query is when you want to do a grouping function on the result of a grouping function. Like count the number of customers who have more than a certain number of orders. Something like: SELECT

Re: [sqlite] Re: Nested SELECT : Alternative syntax please ?

2007-04-08 Thread Jay Sprenkle
On 4/8/07, Igor Tandetnik [EMAIL PROTECTED] wrote: Jaime Castells [EMAIL PROTECTED] wrote: Hmm, I think the only time you really can't avoid a nested query is when you want to do a grouping function on the result of a grouping function. Like count the number of customers who have more than

[sqlite] Re: Re: Nested SELECT : Alternative syntax please ?

2007-04-08 Thread Igor Tandetnik
Jay Sprenkle [EMAIL PROTECTED] wrote: On 4/8/07, Igor Tandetnik [EMAIL PROTECTED] wrote: Jaime Castells [EMAIL PROTECTED] wrote: Hmm, I think the only time you really can't avoid a nested query is when you want to do a grouping function on the result of a grouping function. Like count the

[sqlite] What would you suggest?

2007-04-08 Thread Lloyd
Hi, I want to store and retrieve sorted integer (these integers are file offsets). So do I have to use SQLite or shall I store it in a file? (Reading from the file will be easy by using fseek()). Which would be efficient? SQLit or this file way? or do you have any other suggestions? (In this