"Robert Citek" <[email protected]> wrote in message news:[email protected] > How can I construction a SQL query to pick the top three (3) items in > a group? > > I have a list of sports teams which are grouped into divisions, say A, > B, C, D, etc. At the end of the season I would like to get a list of > the top three teams (those with the most wins) in each division. If I > wanted the best team from each division, I could write this: > > select div, team, max(wins) from teams group by div ;
select div, team from teams t1 where rowid in (select rowid from teams t2 where t1.div = t2.div order by wins desc limit 3); Igor Tandetnik _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

