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

SELECT RPAD(B1.ID, 12) As "MainBranchID",
RPAD(B1.Name, 30) As "Name",
RPAD(COUNT(B2.ID), 14) As "SubBranchCount"
FROM Branch B1, Branch B2
WHERE B1.MainBranchID IS NULL
      AND B2.MainBranchID = B1.ID
GROUP BY B1.ID, B1.Name
HAVING LOWER(B1.Name) LIKE LOWER('%&bname%');
