Subject Problem with aggregate query
Author David Wessell
Hi..

In this specific instance I'm working with two tables, and trying to
get some aggregate information out of one of them.

The two tables are header and detail. The primary key of header is
header_auto_key, and that appears in the detail table as a foreign key.

When I run the query: SELECT sum(total_price) FROM header; I get a
correct result.

If I run: SELECT sum(total_price) FROM header, detail WHERE
header.header_auto_key = detail.header_auto_key; I get an incorrect
result.

With the last example, duplicate values (total_price) are returned
from the header table. The total_price field does not exist in the
detail table.

It's a long drawn out story, why I would need to run a query like the
second option. But I thought someone might have a suggestion as to how
I could restructure that second query, to filter out duplicate results..

Thanks
David