Re: Count the children

Поиск
Список
Период
Сортировка
Искать
От
Sean Davis
Тема
Re: Count the children
Дата
Msg-id
264855a00908180807y25fdc55fja9f7854972591084@mail.gmail.com
Ответ на
Список
Дерево обсуждения
Count the children Michael Rowan <mike.rowan@internode.on.net>
Re: Count the children Mark Styles <postgres@lambic.co.uk>
Re: Count the children Michael Rowan <mike.rowan@internode.on.net>
Re: Count the children Sean Davis <sdavis2@mail.nih.gov>
Re: Count the children Sean Davis <sdavis2@mail.nih.gov>


On Tue, Aug 18, 2009 at 10:50 AM, Sean Davis <sdavis2@mail.nih.gov> wrote:


On Tue, Aug 18, 2009 at 10:34 AM, Michael Rowan <mike.rowan@internode.on.net> wrote:
I need what sounds like a very simple query - but I'm darned if I can figure it out.

I have two tables, parent and child related by child.parent_id = parent.id
The query should return, for each parent row, parent.name and number of child rows

Hi, Michael.

select parent.name,count(*) from parent join child on child.parent_id=parent.id;

I missed a "group by parent.name" above.
 

Sean



В списке pgsql-novice по дате отправления
От: Mark Styles
Дата:
Сообщение: Re: Count the children
От: The PandaWare Company
Дата:
Сообщение: su not working with psql
FAQ