>      select    when_stopped as when_happened,
>                1 as order_hint
>      from      transaction t
>      where     '2005-10-25 15:00:00' <= when_stopped
>        and     when_stopped <= '2005-10-26 10:00:00'
>      union all
>      select    when_stopped as when_happened,
>                2 as order_hint
>      from      transaction t
>      where     '2005-10-25 15:00:00' <= when_stopped
>        and     when_stopped <= '2005-10-26 10:00:00'
>      order by  when_happened, order_hint;

hmm, try pushing the union into a subquery...this is better style
because it's kind of ambiguous if the ordering will apply before/after
the union.

select q.when from
(
 select 1 as hint, start_time as when [...]
 union all
 select 2 as hint, end_time as when [...]
) q order by q.seq, when

question: why do you want to flatten the table...is it not easier to
work with as records?

Merlin
 

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Reply via email to