Re: Counting rows from two tables in one query - Mailing list pgsql-sql

From Greg Sabino Mullane
Subject Re: Counting rows from two tables in one query
Date
Msg-id f7bb0dd795c7fb17b53e1f20cc2cf765@biglumber.com
Whole thread Raw
In response to Counting rows from two tables in one query  (Stefan Weiss <spaceman-75e1f-20040422@ausgehaucht.sensenmann.at>)
List pgsql-sql
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

                
 
> What I am trying to get is a list that shows how many records from
> 'sub_a' and 'sub_b' are referencing 'main':
                                                
 
SELECT id, (SELECT COUNT(*) FROM sub_a WHERE sub_a.main_id=main.id), (SELECT COUNT(*) FROM sub_b WHERE
sub_b.main_id=main.id)
FROM main ORDER BY id;
                         
 
- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200404092128
-----BEGIN PGP SIGNATURE-----
iD8DBQFAd03pvJuQZxSWSsgRAuDuAJ0elm2bPjgC1bGPHnrotzXrPKCt4ACdFytf
BglMm6IouFFZt1c19zST5ac=
=7DbY
-----END PGP SIGNATURE-----




pgsql-sql by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Crypt() encryption
Next
From: "scott.marlowe"
Date:
Subject: Re: pgsql multi-database queries