Sum points per round when winning team takes every game

N

NeoFax

I am helping a friend build a database that calculates how many points
a team earned by round for a given date. Here is the SQL for the
query, but it does not work:

SELECT tblResults_Points.Date, tblResults_Points.Round,
tblResults_Points.Team1, Sum(tblResults_Points.Points1) AS LP
FROM tblResults_Points INNER JOIN (SELECT tblResults_Points.Round,
tblResults_Points.Date,
Sum(Points) AS WinPoints
FROM tblResult_Points
WHERE Date=(SELECT Max(Date) AND Round=(Select Max(Round)
FROM tblResult_Points)
GROUP BY Date, Round
) AS XX ON (tblResult_Points.Date = XX.Date) AND
(tblResult_Points.Round = XX.Round);

I am trying to add in the Winning team which in the table is Team and
then setting their points to zero if the value in LP is null(haven't
gotten this far yet). How would I go about getting this to work?
Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top