I have a table "Projects" and a table "Report". Projects has a field "plan" and Report a field "actual".
For each project many reports can be made by different employees.
I want to create a query where I can see the sum of the actual of all reports on all projects a employee made together with the sum of the plan of the projects and group it by each employee.
SELECT [Report].[employee], Sum([Report].[actual]), Sum([Project].[plan])
FROM Project INNER JOIN Report ON [Project].[no]=[Report].[projectno]
GROUP BY [Report].[employee];
example:
project p1 has plan = 5
project p2 has plan = 7
employee e1 makes report on p1, actual = 3
employee e1 makes report on p1, actual = 1
employee e1 makes report on p2, actual = 5
When I run the query the sum of the actual is correct (9) but the sum of the plan is 17 instead of 12
How can I change the query to meet my demands? Thank you very much.
For each project many reports can be made by different employees.
I want to create a query where I can see the sum of the actual of all reports on all projects a employee made together with the sum of the plan of the projects and group it by each employee.
SELECT [Report].[employee], Sum([Report].[actual]), Sum([Project].[plan])
FROM Project INNER JOIN Report ON [Project].[no]=[Report].[projectno]
GROUP BY [Report].[employee];
example:
project p1 has plan = 5
project p2 has plan = 7
employee e1 makes report on p1, actual = 3
employee e1 makes report on p1, actual = 1
employee e1 makes report on p2, actual = 5
When I run the query the sum of the actual is correct (9) but the sum of the plan is 17 instead of 12
How can I change the query to meet my demands? Thank you very much.