I need an one step sql statement to retrieve a report
from 3 tables: CLIENT, TRANSACTIONS, PAYMENTS. The link
field is CLIENT_ID. For each client I need to sum all
the amounts found in the TRANSACTIONS and PAYMENTS tables.
It works fine if I (left) join the CLIENT with one of the other tables (using SUM and GROUP BY CLIENT_ID), but when I try to left join with the third table the sums are incorrect (actually it sums up the amounts found in TRANSACTIONS table as many times as the number of records in the PAYMENTS table). Can you help?
from 3 tables: CLIENT, TRANSACTIONS, PAYMENTS. The link
field is CLIENT_ID. For each client I need to sum all
the amounts found in the TRANSACTIONS and PAYMENTS tables.
It works fine if I (left) join the CLIENT with one of the other tables (using SUM and GROUP BY CLIENT_ID), but when I try to left join with the third table the sums are incorrect (actually it sums up the amounts found in TRANSACTIONS table as many times as the number of records in the PAYMENTS table). Can you help?