Three fields table: id-data-date_time, how to get max() and date_time same time?

Поиск
Список
Период
Сортировка
От zxo102 ouyang
Тема Three fields table: id-data-date_time, how to get max() and date_time same time?
Дата
Msg-id 73ccced30911051859m7fcd13a4t93445562af8b9244@mail.gmail.com
обсуждение исходный текст
Ответы Re: Three fields table: id-data-date_time, how to get max() and date_time same time?
Список pgsql-general
Hi everyone, 
   I have a table "test" which has three fields:
 
id      data               date_time
1        2         2009-10-1 12:12:12
1        10       2009-10-1 12:22:10
2        3         2009-10-1 12:10:32
2        1         2009-10-1 12:30:32
 
with the sql:
 
select max(data), id from test where 1=1 group by id
 
I can get
 
10     1
 3      2
 
but I want corresponding "date_time" like
 
10     1   2009-10-1 12:22:10
 3      2   2009-10-1 12:10:32
 
if I use the sql below
 
select max(data), id, date_time from test where 1=1 group by id, date_time
 
that won't give the correct results I want. 
 
Can anybody give me help? Thanks a lot in advance. 
 
ouyang

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

Предыдущее
От: John R Pierce
Дата:
Сообщение: Re: Database connection error, try to reset the connection parameters
Следующее
От: Chris
Дата:
Сообщение: Re: Three fields table: id-data-date_time, how to get max() and date_time same time?