Re: [GENERAL] Select number of children of a parent query

2005-01-02 Thread Joost Kraaijeveld
Hi John, John Sidney-Woollett schreef: Useful to add a title to your messages before you post... It escaped before finishing. How about: select parentid, count(*) as number_of_children from childtable group by parentid order by parentid; It works but can you tell me why this works?

Re: [GENERAL] Select number of children of a parent query

2005-01-02 Thread John Sidney-Woollett
You might need to read a good SQL primer to get a full explanation of this feature. Reading from the docs, http://www.postgresql.org/docs/7.4/interactive/sql-select.html quote The optional GROUP BY clause has the general form GROUP BY expression [, ...] GROUP BY will condense into a single row