A correlated subquery is probably the simplest:
SELECT A.NAME, (SELECT Count(*) FROM B WHERE A.ID = B.A_ID) as BCount
FROM A;
This could also be done by JOINing the tables and GROUPing by ID (you can't group just by name because of potential duplicate names for different IDs) to get the count:
SELECT A.ID, A.NAME, Count(*) as BCount
FROM A
INNER JOIN B ON A.ID = B.A_ID
GROUP BY A.ID, A.NAME;
It's not clear to me which is more efficient.
Jeff Mason
[email protected]