I know how to do count(*)/group by on a single table, but how do I get
a count of related records in a child table? Some of the counts will
be zero.
SELECT
parent.id AS id,
parent.name AS name,
parent.create_date AS create_date,
COUNT(child.id) AS count
FROM parent LEFT JOIN child
Message-
From: pgsql-general-ow...@postgresql.org
[mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Mike Orr
Sent: Thursday, March 31, 2011 2:49 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Counting records in a child table
I know how to do count(*)/group by on a single table
...@postgresql.org] On Behalf Of Mike Orr
Sent: Thursday, March 31, 2011 2:49 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Counting records in a child table
I know how to do count(*)/group by on a single table, but how do I get a
count of related records in a child table? Some of the counts
-general@postgresql.org
Subject: Re: [GENERAL] Counting records in a child table
Thanks. How would I do it with a window function? I thought windows only
compared groups of records in the same table.
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your