Solved

interleaving? table rows in oracle

Posted on 2007-11-21
2
603 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.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
percentage remaining 6 40
Bulk insert into global temporary table 2 43
Pl/SQL Query 31 62
unable to get sorting resultset 15 48
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…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

760 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

20 Experts available now in Live!

Get 1:1 Help Now