Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

SELECT b.branch_id, loan.s LOAN from branch b LEFT OUTER JOIN (SELECT a.open_bra

ID: 3841466 • Letter: S

Question

SELECT b.branch_id, loan.s LOAN

from branch b LEFT OUTER JOIN (SELECT a.open_branch_id, sum(a.avail_balance) s

                             FROM account a INNER JOIN product p

                             ON a.product_cd = p.product_cd

                             WHERE p.product_type_cd='LOAN'

                             GROUP BY a.open_branch_id) loan

ON b.branch_id = loan.open_branch_id

ORDER BY b.branch_id;

Even after:

insert into account (ACCOUNT_ID, PRODUCT_CD, CUST_ID, OPEN_DATE)

           values (35,        'SBL',     1,      to_date('17/APR/23', 'RR/MON/DD'));

insert into account (ACCOUNT_ID, PRODUCT_CD, CUST_ID, OPEN_BRANCH_ID, OPEN_DATE)

           values (55,        'LOAN',     9,      4,             to_date('12/APR/23', 'RR/MON/DD'));

no LOAN output shows up. Why? What needs to be inserted to fix this?


Explanation / Answer

Since you didnt give other tables structure or tables, i am guessing yhr inner query is not giving back results.

As you are grouping by branch_id, can you insert some values for branch ids so that you will get values from subquery which will make the full query work.