Solved

interleaving? table rows in oracle

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

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
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
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

773 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