Need to understand the sql behavior when fetching records in a relationship model.
I have 2 simple tables.
Table Name : One
Table Name: Two
When I run the query
select o.name, sum(o.value) as Total
from one o
inner join two t on o.id = t.one_id
I get back the result which is correct
But As soon as i add another record in Table Two link to record number 1 in Table One, the total is doubled to 10 on running the same aggregate query. I know that when running simple query, sql will return 2 records each will refer to the single relationship but how to tackle this problem?




