"Paul Hilton"
<[EMAIL PROTECTED]> wrote in
message news:[EMAIL PROTECTED]
> I have a query where I wish to limit the number of rows in the result
> per group, but not limit them overall.
>
> So for example if I have a table Intable
>
> Create Table Intable (ID Integer Primary Key, Grp Integer, .....other
> stuff.....);
>
> I would like to select up to a limited number of records for each
> value of grp, say 10.

This seems to work:

select * from
(select distinct grp from Intable) t1, Intable t2
where t2.ID in (select ID from Intable t3 where t3.grp=t1.grp limit 10);

Performance will probably be abysmal. At least create an index on Grp.

Igor Tandetnik 



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

Reply via email to