?
Solved

interleaving? table rows in oracle

Posted on 2007-11-21
2
Medium Priority
?
655 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 74

Accepted Solution

by:
sdstuber earned 800 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

839 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