Group multiple same values from single column


#1

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


#2

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

#3

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


#4

did this part of my reply make sense?


#5

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