I have two tables: tableA and tableB. TableA has a field idA and tableB has a record idB and idBPtrA where idBptrA is a pointer to tableA (one of the idA).
I want, using postgres, to select records from a TableA that have the minimal number of records in tableB.
Something like:
select idA,idB,count(idBPtrA) as c
from tableA,tableB
group by idBPtrA
where idA=idB order by c
This of course doesn't work and gives me an error, but I think it should be very similar to that... Any ideas?