SELECT e.*,t.CustCnt,t.AvgBal
FROM employees e
INNER JOIN (SELECT c.city,COUNT(DISTINCT c.cid) AS CustCnt, AVG(a.balance*1.0) AS AvgBal
FROM customer c
INNER JOIN transactions t
ON t.cid = c.cid
INNER JOIN accounts a
ON a.aid = t.aid
WHERE a.account_type='Checking'
GROUP BY c.city
)t
On t.city = e.city
------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/