Solved

interleaving? table rows in oracle

Posted on 2007-11-21
2
605 Views
Last Modified: 2013-12-19
hi, i have an oracle 9i table (called Vehicles).

it has 3 columns (vehicle_id, measurement_1, measurement_2)

i'd like to create a view from this table that "interleaves" the values of measurement_1 and measurement_2.  not sure if "interleave" is the right verb and google hasn't helped.

e.g. the vehicles table's rows might look like this (values separated by commas):

1, 55.2, 58
2, 80, null
3, 40, 42
4, null, 18

i'd like the resulting view to display

1, 55.2
1, 58
2, 80
2, null
3, 40
3, 42
4, null
4, 18


which essentially "merges" the 2 columns called "measurement_1" and "measurement_2"

i feel like this is going to be a head-slapper when I finally figure it out, but right now i'm stumped as to how to merge these 2 columns into 1.

any ideas?
thanks!
0
Comment
Question by:pdanese
2 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 200 total points
ID: 20331004
select id, decode(n,1, measure1,2,measure2) measure
from vehicles,(select 1 n from dual union all select 2 n from dual)
order by id,n
0
 

Author Closing Comment

by:pdanese
ID: 31410471
thank you very much!  awesome.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now