Try this..
SELECT p.name, sum(s.stat1), sum(s.stat2) FROM stats s JOIN Players p ON p.ID = s.playerID WHERE s.gameID IN (SELECT gameID FROM games ORDER BY gameID DESC LIMIT 5) GROUP BY p.playerID HTH, Sam On Thu, Feb 21, 2008 at 10:25 AM, RBKanso <[EMAIL PROTECTED]> wrote: > > Assume the following table structure: > > http://www.nabble.com/file/p15613178/sbtables.jpg > > I can get overall player stats for ALL games using this select statement: > > SELECT p.name, sum(s.stat1), sum(s.stat2) > FROM stats s JOIN Players p ON p.ID = s.playerID > GROUP BY p.ID > > And I can get a summary of stats for the last FIVE games with this call: > > SELECT g.date, g.opponent, g.result, sum(s.stat1), sum(s.stat2) > FROM stats s JOIN games g ON g.ID = s.gameID > GROUP BY g.ID > ORDER BY g.date DESC > LIMIT 0,5 > > But how would I get the overall PLAYER stats for the last FIVE games? > > I have tried sub-queries and additional joins but this type of SELECT is > simply above my knowledge of SQL. I appreciate any help. Thanks. > -- > View this message in context: > http://www.nabble.com/Multiple-table-SELECT-help-tp15613178p15613178.html > Sent from the SQLite mailing list archive at Nabble.com. > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users