Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Hopefully Stupid Question

Re: Hopefully Stupid Question

From: Amy Ellis <purpleladyamy_at_yahoo.com>
Date: 5 Jun 2002 12:41:23 -0700
Message-ID: <5b31275a.0206051141.18001d3f@posting.google.com>


Had that issue myself awhile ago. How about this:

create or replace view my_view as
select distinct t1.ts d
from table1 t1
union select distinct t2.ts d
from table2 t2
union select distinct t3.ts d
from table3 t3
order by d

Timestamps don't necessarily need to be distinct. That will give you a list of all the timestamps. Then:

select d,
  NVL((SELECT t1.data FROM table1 t1)
  where t1.d = my_view.d) ,0) data1,
  NVL((SELECT t2.data FROM table2 t2)
  where t2.d = my_view.d) ,0) data2,
  NVL((SELECT t3.data FROM table3 t3)
  where t3.d = my_view.d) ,0) data3,
from my_view
order by d desc

That will give you 4 columns.
Don't have time to think about how to get it into only 2 columns, sorry.  

Hope it helps!

Amy Ellis Received on Wed Jun 05 2002 - 14:41:23 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US