Can anyone help me to fix this SQL query.
Select c.name, c.address, c.area, sum(i.amount) from customers c
Inner Join invoices i on c.id=i.customer_id
Inner Join invoice_payments p on i.id = p.invoice_id
group by c.name
Here is tables structure
Customer Table
id(int), Name(string), Area(string), Address(string)
Invoices Table
id(int), Invoice_Number (string), customer_id(int), amount(decimal)
Invoice_payments
id(int), invoice_id(int), amount(decimal)
I have two payment records of one client in invoice_payments table so it's returning double amount of that client...
How i can fix this issue