Sql problems in large databases

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Sql problems in large databases

mawais31
I have a large database, Where I have two tables claims and invoices. In invoice table when I run the query

select sum(amount) from invoices.
Gives me value of 207859507

However when I join two tables and group then by one variable such as mileage in claim table


SELECT c.mileage, SUM(i.amount) AS amount
FROM claims c
INNER JOIN invoices i
  ON i.ID = c.ID AND i.accident_date = c.accident_date
GROUP BY mileage

it gives me a greater value i.e. 214110863...

But conceptually the join must have smaller value then the other query

Regards