[sqlite] Tricky SQL

2015-11-17 Thread Bart Smissaert
With a compound index on ID and DATE performance is fine. Thanks again. RBS On Tue, Nov 17, 2015 at 12:45 AM, Bart Smissaert wrote: > Actually it is slower than I thought, taking some 90 secs for only 7000 > records. > Will if any compound index can speed this up. > > RBS > > On Tue, Nov 17, 20

[sqlite] Tricky SQL

2015-11-17 Thread Bart Smissaert
Actually it is slower than I thought, taking some 90 secs for only 7000 records. Will if any compound index can speed this up. RBS On Tue, Nov 17, 2015 at 12:09 AM, Igor Tandetnik wrote: > On 11/16/2015 6:37 PM, Bart Smissaert wrote: > >> Now, what I need is for every row the count of preceding

[sqlite] Tricky SQL

2015-11-17 Thread Bart Smissaert
Thanks for that. I find that an amazing solution and one that I would never have come up with. Indeed a lot simpler (for me, that is) in application code, but for my purpose this SQL is fine as my numbers are small, thousands at most. RBS On Tue, Nov 17, 2015 at 12:09 AM, Igor Tandetnik wrote:

[sqlite] Tricky SQL

2015-11-16 Thread Bart Smissaert
Trying to get my head around a tricky SQL and maybe somebody can help me out here: CREATE TABLE TEST( [ID] INTEGER, [DATE] TEXT, [VALUE] REAL ) Example data: ID DATEVALUE - 1 2015-01-01 14 1 2015-02-01 16 1 2015-03-01 11 1 2015-04-0

[sqlite] Tricky SQL

2015-11-16 Thread Igor Tandetnik
On 11/16/2015 6:37 PM, Bart Smissaert wrote: > Now, what I need is for every row the count of preceding rows where > the ID is the same as the ID of the current row, the date is less than the > date of the current row and the value is >= 10 and <= 20. If the value is > outside > this range then it

[sqlite] Tricky SQL Statement

2005-04-30 Thread Murray Moffatt
I wonder if someone could please help me with a tricky SQL statement that I'm trying to create in SQLite. I have four tables: Charts, Colours, MaterialTypes, Materials. There is a one-to-many relationship between the Charts and Colours (i.e. each Chart can have 0 or more Colours). There is a