Skip site navigation (1) Skip section navigation (2)

Re: Postgres-sql-php

From: "Oliveiros Cristina" <oliveiros(dot)cristina(at)gmail(dot)com>
To: "Zied Kharrat" <khzied(at)gmail(dot)com>
Cc: "Oliveiros Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Postgres-sql-php
Date: 2008-10-23 13:25:45
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
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 condition on the right outer join coz it would
give trouble if two childs happened to be of the same age.

I guess it will never happen two childs with the same name :p


SELECT a.num,a.father,b.child,b.age
SELECT num,father, MIN(child)as primeira
GROUP BY num,father) a
ON b.child = a.primeira
AND b.father = a.father
AND a.num = b.num

even the biggest failure, even the worst mistake, beats the hell out of
never trying...
- Meredith Grey

2008/10/23 Zied Kharrat <khzied(at)gmail(dot)com>

> hi,
> i don't want any sort..  just like this example
> *num  father  child     age  col5
> *1       joe     bruce    14       8
>                    lei         10
>                    mike     5
> 2    manuel  child1    35      16
>                   child2    33
>                   child3   30
> this is what i want really..
> What can be then the sql request without sort with this update.. Thanks :)

In response to


pgsql-sql by date

Next:From: Steve MidgleyDate: 2008-10-23 16:08:48
Subject: Re: grouping/clustering query
Previous:From: Zied KharratDate: 2008-10-23 12:46:43
Subject: Re: Postgres-sql-php

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group