Re: How can I group all children by their parent ?

From: David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How can I group all children by their parent ?
Date: 2014-07-17 13:42:35
Message-ID: 1405604555571-5811851.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Arup Rakshit wrote
> ORDER BY parent_id, id ?
>
> François Beausoleil
>
> parent_id .. But why order_by.. I thought I need to group by
>
> parent child email
>  1      2        

> test1@

>                 3        email

The word "group" as you have used it can mean:

"Generate a single record for each parent with all children combined into
that record."

or

"Physically order the output so that while each child still has its own
record all children of the same parent are listed consecutively"

The first solution requires GROUP BY, the second requires ORDER BY

It would help if you could show an example of what you want the output to
look like.

David J.

--
View this message in context: http://postgresql.1045698.n5.nabble.com/How-can-I-group-all-children-by-their-parent-tp5811846p5811851.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message D'Arcy J.M. Cain 2014-07-17 13:48:53 Re: How can I group all children by their parent ?
Previous Message Arup Rakshit 2014-07-17 13:28:14 Re: How can I group all children by their parent ?