ACCEPT bname PROMPT 'Please enter part of the branch name: ';

SELECT RPAD(Name, 30) As "BranchName",
RPAD(COUNT(Accidents.ID), 20) As "AccidentCount"
FROM Branch, Accidents
WHERE Accidents.ID IN (
      SELECT Accidents.ID
      FROM T_b, T_c, Ac_c
      WHERE T_b.BranchID = Branch.ID
            AND T_b.TransID = T_c.TransID
            AND T_c.CustID = Ac_c.CustID)
GROUP BY Name
HAVING LOWER(Name) LIKE '%&bname%';
