If i have Two tables
First
QuestionID(primary key) | Target value | |
1 | 100 | |
Second table
RecordID(primary key) | Achieved value | QuestionID (FORIGN KEY) |
1 | 123 | 1 |
2 | 432 | 1 |
When i want to calculate the sum using Inner join i.e.
SELECT SUM(TargetValue) AS TARGET ,SUM(AchievedValue) AS ACHIEVED FROM First
INNER JOIN Second AS S ONS.QuestionID=First.QuestionID
Where 1=1
Then it gives me SUM OF TARGET VALUE 200 Instead of 100 Why???