Re: need to join successive log entries into one

Поиск
Список
Период
Сортировка
От Richard H
Тема Re: need to join successive log entries into one
Дата
Msg-id 20010314.21173300@client.archonet.com
обсуждение исходный текст
Ответ на need to join successive log entries into one  (George Young <gry@ll.mit.edu>)
Ответы Re: need to join successive log entries into one  ("Ross J. Reedstrom" <reedstrm@rice.edu>)
Список pgsql-sql

>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 3/14/01, 5:24:12 PM, George Young <gry@ll.mit.edu> wrote regarding [SQL] 
need to join successive log entries into one:


> I have a table like:

> run   | seq   | start                | done
>   1415|    261| 2001-01-29 12:36:55| 2001-02-07 13:02:38
>   1415|    263| 2001-02-14 07:40:04| 2001-02-15 16:05:04
>   1415|    264| 2001-02-16 16:05:05| 2001-03-08 16:34:03
>   1415|    265| 2001-03-08 16:34:04|

> This is a log of some operations done on some runs. 'seq' is the step
> within the run.

> I need to produce a new table that coalesces immediately successive
> operations on a run into one, e.g.:

> run   |  start               | done
>   1415|  2001-01-29 12:36:55| 2001-02-07 13:02:38
>   1415|  2001-02-14 07:40:04|
>   1747|  2001-02-15 09:14:39| 2001-03-01 09:02:39
>   1747|  2001-03-05 13:13:58|
>   1954|  2001-02-02 20:55:39| 2001-03-02 10:17:15

Try:

select run,min(start),max(done) from mytable group by run;

- Richard Huxton


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

Предыдущее
От: Richard H
Дата:
Сообщение: Re: PL/pgSQL "compilation error"
Следующее
От: Richard H
Дата:
Сообщение: Re: pl/Perl