[SQL] Postgres-sql-php

2008-10-23 Thread Zied Kharrat
Hi Everybody.. Let's present my problem: I have a table named *t1* and i will insert differents values like this : insert into t1 (num,father,child,age) values ('1','joe','bruce','14',); insert into t1 (num,father,child,age) values ('1','joe','lei','10',); insert into t1 (num,father,child,age) v

Re: [SQL] SELECT multiple MAX(id)s ?

2008-10-23 Thread Aarni
On Tuesday 14 October 2008 18:27:01 Fernando Hevia wrote: > > -Mensaje original- > > De: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] En nombre de Aarni Ruuhimäki > > Enviado el: Viernes, 10 de Octubre de 2008 07:56 > > Para: pgsql-sql@postgresql.org > > Asunto: [SQL] SELECT multiple MAX

Re: [SQL] Postgres-sql-php

2008-10-23 Thread Oliveiros Cristina
Howdy, Zied. The query below outputs the results as you want, but I suspect you have a more general situation you want to solve. If you have more than one father, say "manuel", you would want something like this ? num father child age 1 joe bruce14 lei

Re: [SQL] Postgres-sql-php

2008-10-23 Thread Zied Kharrat
hi, i don't want any sort.. just like this example *num father child age col5 *1 joe bruce14 8 lei 10 mike 5 2manuel child135 16 child233 child3 30 this is what

Re: [SQL] Postgres-sql-php

2008-10-23 Thread Oliveiros Cristina
Just add two conditions on the previous query A particularity of this approach is that the non-null record will always appear with the first child in alphabetical order. But, according to what you explain, I guess it is OK, and if it doesn't it is easily changed. :-) Also I've changed the first c

Re: [SQL] grouping/clustering query

2008-10-23 Thread Steve Midgley
At 10:20 PM 10/22/2008, you wrote: Message-ID: <[EMAIL PROTECTED]> Date: Wed, 22 Oct 2008 12:14:49 +0700 From: "David Garamond" <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Subject: grouping/clustering query X-Archive-Number: 200810/89 X-Sequence-Number: 31731 Dear all, I have an invoices

Re: [SQL] Postgres-sql-php

2008-10-23 Thread Oliveiros Cristina
I guess you can change a little the query to your needs. The problem is pretty much the same... I've used c3 column in equality, but if this column has repeated values, just choose any column or combination of columns which is unique. Best, Oliveiros SELECT a.c1,a.c2,b.c3,b.c4,a.c5,b.c6 FROM ( SE

Re: [SQL] grouping/clustering query

2008-10-23 Thread Joe
Steve Midgley wrote: # (invoiceid, txid) (A, 1) (A, 3) (B, 1) (B, 2) (C, 5) (D, 6) (D, 7) (E, 8) (F, 8) For journalling, I need to group/cluster this together. Is there a SQL query that can generate this output: # (journal: invoiceids, txids) [A,B] , [1,2,3] [C], [5] [D], [6,7] [E,F], [8] Hi