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

merge timestamps to intervals

From: Patrick Scharrenberg <pittipatti(at)web(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: merge timestamps to intervals
Date: 2008-05-12 05:38:47
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql

I have a table where I repeatingly log the status of some service, which
looks something like this:

	< timestamp, status >

Now, everytime my service is up I save the timestamp and a status of
"up", if it's down I save the timestamp with "down", eg:
	10:13	up
	10:14	up
	10:15	up
	10:16	down
	10:17	up
	10:18	up

I'd like to merge this information to intervals where the service was up
or down.

	< intervall, status >
	10:13-10:15	up
	10:16-10:16	down
	10:17-1018	up

I've no clue how to approach this problem.

Any ideas/hints?
Also suggestions on a feasible better schema are welcome. :-)



pgsql-sql by date

Next:From: Craig RingerDate: 2008-05-12 06:33:03
Subject: Re: merge timestamps to intervals
Previous:From: Mag GamDate: 2008-05-12 00:58:28
Subject: Re: Difference in columns

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