Re: Query Assistance - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Query Assistance
Date
Msg-id 476042C1.8070707@archonet.com
Whole thread Raw
In response to Re: Query Assistance  ("Gary Chambers" <gwchamb@gmail.com>)
List pgsql-sql
Gary Chambers wrote:
> D'Arcy...
> 
>> Have you considered this?
> 
> I considered integrating the begin and end times into the table.  I'm
> capturing the data via ACPI events, so it's "transactional" by nature.
> I want to be able to keep track of false transitions (hence the
> is_outage field).
> 
> I'm looking for a way to simplify the transitions output on my web
> browser, and I want to combine an offline and a corresponding online
> time into a single line.

How about a "paired_with" field that references the power_transitions 
table and a trigger. When you insert a new row, it checks what the 
previous row was - if it's a down & this is an up, then set the 
paired_with field on each.

--   Richard Huxton  Archonet Ltd


pgsql-sql by date:

Previous
From: "Rodrigo De León"
Date:
Subject: Re: Query design assistance - getting daily totals
Next
From: "Rolf A. de By"
Date:
Subject: Trigger definition . . . puzzled