G
Guest
I have 2 tables, EnrollmentDetails and Payments; the former lists all details
for another table Enrollment and has a compound Primary Key (EnrollmentID &
ContactID) I want to create a query that sums a value in EnrollemtDetails
(Price) and Subtracts the sum of a value from the joined Payments table. The
tables are joined by EnrollmentID. Whenever I create a simple query to sum
the values in EnrollmentDetails I get accurate values: SELECT EnrollmentID,
SUM(Price) AS Balance
FROM dbo.EnrollmentDetails
GROUP BY EnrollmentID
Yields:
EnrollmentID Balance
9 $600.00
12 $300.00
13 $800.00
14 $600.00
But when I add the joined table to the query view, without even selecting
new output fields, the values from the original fields change:
SELECT dbo.EnrollmentDetails.EnrollmentID,
SUM(dbo.EnrollmentDetails.Price) AS Balance
FROM dbo.EnrollmentDetails INNER JOIN
dbo.Payments ON dbo.EnrollmentDetails.EnrollmentID =
dbo.Payments.EnrollmentID
GROUP BY dbo.EnrollmentDetails.EnrollmentID
Yields:
EnrollmentID Balance
9 $1,200.00
12 $900.00
13 $800.00
What is happening, is it the compound Primary Key of EnrollmentDetails or am
I using the wrong join? Thanks
for another table Enrollment and has a compound Primary Key (EnrollmentID &
ContactID) I want to create a query that sums a value in EnrollemtDetails
(Price) and Subtracts the sum of a value from the joined Payments table. The
tables are joined by EnrollmentID. Whenever I create a simple query to sum
the values in EnrollmentDetails I get accurate values: SELECT EnrollmentID,
SUM(Price) AS Balance
FROM dbo.EnrollmentDetails
GROUP BY EnrollmentID
Yields:
EnrollmentID Balance
9 $600.00
12 $300.00
13 $800.00
14 $600.00
But when I add the joined table to the query view, without even selecting
new output fields, the values from the original fields change:
SELECT dbo.EnrollmentDetails.EnrollmentID,
SUM(dbo.EnrollmentDetails.Price) AS Balance
FROM dbo.EnrollmentDetails INNER JOIN
dbo.Payments ON dbo.EnrollmentDetails.EnrollmentID =
dbo.Payments.EnrollmentID
GROUP BY dbo.EnrollmentDetails.EnrollmentID
Yields:
EnrollmentID Balance
9 $1,200.00
12 $900.00
13 $800.00
What is happening, is it the compound Primary Key of EnrollmentDetails or am
I using the wrong join? Thanks