What version are you using?
Current sources allow this, and 7.0.2 should as well.
sszabo=# select * from a;
a
---
3
4
(4 rows)
sszabo=# select * from b;
a
---
3
4
3
3
(4 rows)
sszabo=# select distinct a, (select count(*) from b where b.a=a.a) from a;
a | ?column?
---+----------
3 | 3
4 | 1
| 0
(3 rows)
Stephan Szabo
sszabo(at)bigpanda(dot)com
On 21 Jul 2000, Manuel Lemos wrote:
> SELECT f1, (SELECT COUNT(*) FROM t2 WHERE t2.f2=t1.f1) AS my_count FROM t1