-
Please help with this query problem
Hello
I've found this forum while trying to find a resolution to a problem that has been haunting me the entire day today. I cannot get the SUM to properly calculate values when joining two tables together.
I have two tables:
Table A (Math)
----------
Student ID, Marks (out of 100 each)
-----------------------------------------
20001, 75
20001, 85
------------------------------------------
Table B (Science)
----------
Student ID, Marks
------------------------------------------
20001, 60
20001, 40
------------------------------------------
What I am trying to do is get a query that will SUM the marks for math and science for this student and display them as follows
Math, Science
----------------
160, 100
My query calculates the math fine, but science doesn't add up.
Select SUM(a.Marks) as "Math", SUM(b.Marks)as "Science"
from Table A as a
JOIN Table B as b on a.StudentId = b.StudentId
Where a.StudentId = 20001
I've tried different variations of the query, and if I take it apart it sums both properly, but when joined the Science is wrong.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|