Group multiple same values from single column

Image contains 4 tables customer,loans,ltrans and result table

How can i group using gp_name from customer table to create rseult table from there tables
there 3 table s customer, loans , ltrans which i need to group to make table Result.
i need to group information using gp_name fom customer table to like in the result table in the image.
Ltrans_table

no idea how the calculations are supposed to be done, but here’s the structure of the query that you need… adjust as required

SELECT c.gp_name , SUM(l.loan_p) AS loan_p , SUM(t.unpaidp) AS unpaidp , SUM(t.upaidi) AS upaidi , SUM(l.loan_p) - SUM(t.unpaidp) AS balance FROM customer AS c INNER JOIN loan AS l ON l.cust_id = c.cust_id INNER JOIN ltrans AS t ON t.loan_id = l.loan_id GROUP BY c.gp_name

i really appreciate your help query works but gives wrong values starting from column loan_p to column balance in result table

did this part of my reply make sense?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.