Sum By Group in Access 2016 Query

If you want the total number of runs for each venue, then a simple aggregation query does what you want:

SELECT Matches.venue, SUM(runs) AS TOTAL
FROM Matches INNER JOIN
     ScorecardBatting
     ON Matches.matchId = ScorecardBatting.matchId
GROUP BY Matches.venue;

If you want this in your original query, you could join it in:

select . . ., t.total
from Matches inner join
     ScorecardBatting
     on Matches.matchId = ScorecardBatting.matchId join
     (select Matches.venue, sum(runs) AS TOTAL
      from Matches INNER JOIN
           ScorecardBatting
           on Matches.matchId = ScorecardBatting.matchId
      group by Matches.venue
     ) t
     on t.venue = matches.venue;

I don’t think you need a group by fro your query.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top