Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Hopefully Stupid Question
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:53 CDT
![]() |
![]() |