2008/12/1 Igor Tandetnik <[EMAIL PROTECTED]>:
> Try this:
>
> select n from map
> group by n
> having
>    count(case when m=3 then 1 else null end) != 0 and
>    count(case when m=5 then 1 else null end) != 0 and
>    count(case when m=7 then 1 else null end) = 0;
>
> Having an index on map(n) should speed it up.

Thank you very much, Igor. I would have not thought of that.

This is a nicely predictable single linear scan. Still not awfully
fast, but it will have to do.
Using an index on map(n,m) seems faster. This may be because the m
values are in the index and there is no need to access the table.

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

Reply via email to