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! ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq