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] 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] 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
s SELECT a.num,a.father,b.child,b.age FROM ( SELECT num,father, MAX(age)as maximo FROM t1 GROUP BY num,father) a RIGHT JOIN t1 b ON b.age = a.maximo - Original Message - From: Zied Kharrat To: pgsql-sql@postgresql.org Sent: Thursday, October 23, 2008 9:14 AM Subject: [SQL] Po

[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