From: Gary Chambers <gwchamb@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Query Assistance
Date: Wed, 12 Dec 2007 11:58:20 -0500
Message-ID: <302670f20712120858k210dd812l8b232ce98d5d162f@mail.gmail.com> (raw)
All...
I have a simple table in PostgreSQL 8.2.5:
CREATE TABLE power_transitions (
-- Transition ID (PK)
tid integer NOT NULL,
-- State ID (0 = Unknown, 1 = Online (AC power), 2 = Offline (Battery)
sid smallint NOT NULL,
-- Timestamp of transition
statetime timestamp without time zone DEFAULT now() NOT NULL,
-- Is this a real outage?
is_outage boolean DEFAULT true NOT NULL
);
It contains a log of power outages (transitions). I'd like to create
query that returns a transition offline time and associated return to
online time. Is there a better way of handling this? I am open to
schema change suggestions. Thanks very much!
-- Gary Chambers
// Nothing fancy and nothing Microsoft!
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: gwchamb@gmail.com
Subject: Re: Query Assistance
In-Reply-To: <302670f20712120858k210dd812l8b232ce98d5d162f@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox