Hi there,
What I want is to obtain summary information only on data in
Table A, regardless of any joins with other tables. Normally
if you say for example
SELECT Sum(TableA.Amount), Sum(TableB.Amount) FROM
TableA LEFT JOIN TableB ON TableA.ID = TableB.LinkID,
you will get NOT the sum the TableA.Amount as such, but
rather a sum of the data in TableA where each record
is duplicated for every matching record in TableB. Thus,
say the data is like:
TableA
ID Amount
1 10
2 20
3 30
TableB
LinkID Amount
1 10
1 10
1 10
2 10
The result of the above SELECT statement will be
Sum(TableA.Amount) Sum(TableB.Amount)
80 40
80 is (10 + 10 + 10) + 20 + 30,
the 10 being repeated 3 times, as TableB as three records
which match with the first record in TableA.
So, HOW do I get the absolute sum of the Amount in TableA,
within one SQL statement? Or must you use two SQL statements,
which is what I'm doing currently.
Thanks in advance for any help,
mmarseil
What I want is to obtain summary information only on data in
Table A, regardless of any joins with other tables. Normally
if you say for example
SELECT Sum(TableA.Amount), Sum(TableB.Amount) FROM
TableA LEFT JOIN TableB ON TableA.ID = TableB.LinkID,
you will get NOT the sum the TableA.Amount as such, but
rather a sum of the data in TableA where each record
is duplicated for every matching record in TableB. Thus,
say the data is like:
TableA
ID Amount
1 10
2 20
3 30
TableB
LinkID Amount
1 10
1 10
1 10
2 10
The result of the above SELECT statement will be
Sum(TableA.Amount) Sum(TableB.Amount)
80 40
80 is (10 + 10 + 10) + 20 + 30,
the 10 being repeated 3 times, as TableB as three records
which match with the first record in TableA.
So, HOW do I get the absolute sum of the Amount in TableA,
within one SQL statement? Or must you use two SQL statements,
which is what I'm doing currently.
Thanks in advance for any help,
mmarseil