Re: Min and Max

Поиск
Список
Период
Сортировка
От Dennis Björklund
Тема Re: Min and Max
Дата
Msg-id Pine.LNX.4.44.0212021939410.9578-100000@zigo.dhs.org
обсуждение исходный текст
Ответ на Min and Max  (smoshiro@hotmail.com (Sergio Oshiro))
Список pgsql-sql
On 29 Nov 2002, Sergio Oshiro wrote:

> How can I get the rows of the children name and its "father" such that
> they have the min child_ages?
> 
> -- the following does not return the child_name...
> select id_father, min(child_age) from children group by id_father;
> select id_father, max(child_age) from children group by id_father;

You could join one of the above with the table itself and get the result.  
Something like

select * from (  select id_father, min(child_age)           from children       group by id_father) as r,
childrenwherechildren.id_father = r.id_father  and children.min = r.min;
 

-- 
/Dennis



В списке pgsql-sql по дате отправления:

Предыдущее
От: Joel Burton
Дата:
Сообщение: Re: CURRENT_TIMSTAMP
Следующее
От: Joel Burton
Дата:
Сообщение: Re: Min and Max