Igor Tandetnik <[email protected]> wrote:
> Your statement is equivalent to this simpler one:
> 
> INSERT INTO a
> SELECT 'Item',
> x.Item,
> strftime('%Y-%m-%d',max(TheDate)),
> 
> strftime('%Y-%m-%d', max(TheDate),
>    (select skippedweeks from c
>     where Item = x.Item and Frequency = max(y.Frequency)) * 7 || ' days'),

This part could be simplified further (assuming skippedweeks is between 0 and 
1,000,000; adjust to taste):

strftime('%Y-%m-%d', max(TheDate),
    (max(Frequency * 1000000 + skippedweeks) % 1000000 * 7) || ' days')

This way, index on c(Item, Frequency) is no longer necessary, one on c(Item) 
would suffice.
-- 
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to