I am trying to inner join these 2 subqueries (I think that's what it's called anyways) together where the branchName of the first query is equal to the branchName of the second query.
However, they don't seem to want to join together, and with my limited knowledge of SQL I can't seem to find a way to fix this. I tried moving the brackets around in all sorts of positions but it didn't like that either.
SELECT *
FROM
(
SELECT B.branchName, A.type, AVG (T.amount), COUNT(A.accNumber)
FROM Branch B, Account A, Transactions T
WHERE
B.branchNumber = A.branchNumber AND
A.accNumber = T.accNumber
GROUP BY B.branchName, A.type
)
INNER JOIN
(
SELECT B1.branchName, COUNT(A1.accNumber)
FROM Account A1, Branch B1
WHERE
A1.branchNumber = B1.branchNumber
GROUP BY B1.branchName
HAVING COUNT(A1.accNumber) > 5
)
ON
B.branchName = B1.branchName