,(SELECT COUNT(*) FROM employee emp1 WHERE emp1.dept_id=department.dept_id) cnt
SELECT
employee.fname as fname
, employee.lname as lname
, branch.name as bname
, department.name as dname
, COUNT(*) OVER(PARTITION BY department.name)
FROM employee
JOIN branch
ON employee.assigned_branch_id = branch.branch_id
JOIN department
ON employee.dept_id = department.dept_id
SQL-запрос 1-й таблицы:
SELECT employee.fname as fname, employee.lname as lname, branch.name as bname, department.name as dname
FROM employee JOIN branch ON employee.assigned_branch_id=branch.branch_id
JOIN department ON employee.dept_id=department.dept_id
SQL-запрос 2-й таблицы:
SELECT department.name , COUNT(employee.emp_id)
FROM department JOIN employee ON department.dept_id=employee.dept_id
GROUP BY department.name