Query Assistance

From: "Gary Chambers" <gwchamb(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Query Assistance
Date: 2007-12-12 16:58:20
Message-ID: 302670f20712120858k210dd812l8b232ce98d5d162f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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!

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message D'Arcy J.M. Cain 2007-12-12 17:31:29 Re: Query Assistance
Previous Message Scott Marlowe 2007-12-12 15:48:05 Re: Query design assistance - getting daily totals