Re: matching against start/end times and diagnostic values

Поиск
Список
Период
Сортировка
От Seb
Тема Re: matching against start/end times and diagnostic values
Дата
Msg-id 87sihl1znv.fsf@net82.ceos.umanitoba.ca
обсуждение исходный текст
Ответ на filtering based on table of start/end times  (Seb <spluque@gmail.com>)
Список pgsql-sql
On Wed, 12 Nov 2014 15:49:57 -0600,
Seb <spluque@gmail.com> wrote:

> Sorry to come back with a related issue, which is proving troublesome.
> There's another log table, that looks just like voltage_log, but has
> an additional column with an integer indicating what problem occurred
> during the period:

> CREATE TABLE voltage_diagnostic_log ( record_id serial, time_beg
> timestamp without time zone NOT NULL, time_end timestamp without time
> zone NOT NULL, diagnostic integer, CONSTRAINT voltage_log_pkey PRIMARY
> KEY (record_id));

[...]

For posterity's sake, the only solution I was able to find was to first
create a view with a separate boolean column for each diagnostic value
via crosstab().  From there it was possible to use a WITH subquery to
remove rows with a particular diagnostic value (as suggested
previously), and then have the main SELECT statement do a second left
join to the crosstab view so that it could make use of the rest of the
boolean columns as sources for CASE statements for each field.

Cheers,

-- 
Seb




В списке pgsql-sql по дате отправления:

Предыдущее
От: Seb
Дата:
Сообщение: matching against start/end times and diagnostic values (was: filtering based on table of start/end times)
Следующее
От: Tim Dudgeon
Дата:
Сообщение: slow sub-query problem