Query Assistance - Mailing list pgsql-sql

From Gary Chambers
Subject Query Assistance
Date
Msg-id 302670f20712120858k210dd812l8b232ce98d5d162f@mail.gmail.com
Whole thread Raw
Responses Re: Query Assistance
List 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
(ACpower), 2 = Offline (Battery)   sid smallint NOT NULL,   -- Timestamp of transition   statetime timestamp without
timezone 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!


pgsql-sql by date:

Previous
From: "Scott Marlowe"
Date:
Subject: Re: Query design assistance - getting daily totals
Next
From: "D'Arcy J.M. Cain"
Date:
Subject: Re: Query Assistance