Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7952333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:49:50+00:00 2026-06-04T02:49:50+00:00

Background: I am working on a large database that is used to track wire

  • 0

Background:

I am working on a large database that is used to track wire footages. Currently, the database (Oracle) is structured around three main tables:

1) A map detail table. Defines all of the top-level details of a particular map such as county / district / city. Each map is uniquely identified by a serial number that is used in the following tables.

2) A corridor length table. Basically, how long a run of wire is as the crow flies and if that corridor is on public or private land. Thus, the footage defined here is simply the distance from A to B.

3) A wire length table. This table stores information about the different wires that can be run in a given corridor. There is one row for each operating voltage. Thus, a corridor may have several lengths of wire at, for example; 12KV, 33KV, and 66KV.

There will always be a single map record in (1) but there bay be any number of rows in (2) and (3) and the row counts in (2) and (3) usually do not match.

The Question:

I am searching for a method to join these three tables such that each footage is only reported once. This is best illustrated by example. Below is a sample record set:

Map Details:
-------------------------------------------
| SERIAL_NO | CNTY | DIST | MAP_NO (Name) |
|-----------------------------------------|
|         1 |   33 |   88 | 123-4567-8    |
-------------------------------------------

Corridor Details:
------------------------------------
| SERIAL_NO | PROPRTY_CD | CORR_FT |
|----------------------------------|
|         1 |     PUBLIC |     100 |
|         1 |    PRIVATE |     200 |
------------------------------------

Wire Details
---------------------------------
| SERIAL_NO | OPER_KV | WIRE_FT |
|-------------------------------|
|         1 |      12 |     300 |
|         1 |      33 |     200 |
|         1 |      66 |     200 |
---------------------------------

The ultimate output that I am after would be something like the following:

--------------------------------------------------------------------------------------
| SERIAL_NO | CNTY | DIST | MAP_NO (Name) | PROPRTY_CD | CORR_FT | OPER_KV | WIRE_FT |
|------------------------------------------------------------------------------------|
|         1 |   33 |   88 | 123-4567-8    |     PUBLIC |     100 |      12 |     300 |
|         1 |   33 |   88 | 123-4567-8    |    PRIVATE |     200 |      33 |     200 |
|         1 |   33 |   88 | 123-4567-8    |       NULL |    NULL |      66 |     200 |
--------------------------------------------------------------------------------------

NOTE: The wire and corridor footages will not match most of the time (there are wire multipliers and such that are not shown here for brevity’s sake). Also, there may be more rows in the corridor table versus the wire table (a corridor with no wire in it) or vice-versa (a corridor with multiple wires run in it).

I have tried many different approaches to this problem but I can’t seem to get the output I want. Every join I have tried has resulted in values being duplicated as or similar to that which follows:

BAD:
--------------------------------------------------------------------------------------
| SERIAL_NO | CNTY | DIST | MAP_NO (Name) | PROPRTY_CD | CORR_FT | OPER_KV | WIRE_FT |
|------------------------------------------------------------------------------------|
|         1 |   33 |   88 | 123-4567-8    |     PUBLIC |     100 |      12 |     300 |
|         1 |   33 |   88 | 123-4567-8    |     PUBLIC |     100 |      33 |     200 |
|         1 |   33 |   88 | 123-4567-8    |     PUBLIC |     100 |      66 |     200 |
|         1 |   33 |   88 | 123-4567-8    |    PRIVATE |     200 |      12 |     300 |
|         1 |   33 |   88 | 123-4567-8    |    PRIVATE |     200 |      33 |     200 |
|         1 |   33 |   88 | 123-4567-8    |    PRIVATE |     200 |      66 |     200 |
--------------------------------------------------------------------------------------

Summary:

My apologies for the long question, but it is somewhat complex explaining what I am after. Long story short, I want to list all rows in both child tables side by side (in no particular order) while filling in NULL for the columns of the row difference between the two tables. Thank you in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:49:52+00:00Added an answer on June 4, 2026 at 2:49 am

    The task in the way you set it up can be brute-forced in the following way

    --pseudo-tables with sample data
    with t_map  as (select 1 serial_no, 33 cnty,  88 dist, '12345678' map_no from dual),
     t_corr as (select 1 serial_no, 'PUBLIC' property_cd, 100 corr_ft from dual union all
                select 1, 'PRIVATE', 200 from dual),
     t_wire as (select 1 serial_no, 12 oper_kv, 300 wire_ft from dual union all 
                select 1, 33, 200 from dual union all
                select 1, 66, 200 from dual)
    --query itself
    select m.serial_no, m.cnty, m.dist, m.map_no, r.*
      from  t_map m join 
            (select nvl(c.serial_no, w.serial_no)  serial_no, c.property_cd, c.corr_ft, w.oper_kv, w.wire_Ft from (
                            (select t_corr.*, row_number() over(partition by serial_no order by serial_no) rn from t_corr) c 
                  full join (select t_wire.*, row_number() over(partition by serial_no order by serial_no) rn from t_wire) w 
                         on c.serial_no = w.serial_no and (c.rn = w.rn)
                           )
            ) r on r.serial_no = m.serial_no;
    

    However, if I were you I would concern about questions asked in comments to your initial post 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First some background, I am currently working on a relatively large Asp.Net MVC application
I'm working on a site that has a large number of color styles, around
Background: I am writing a C++ program working with large amounts of geodata, and
Some background I'm currently working on a mobile site so I keep switching user
I have a large activity that contains 100 or more buttons. But it's working
Background I recently joined a small start-up after working at a large company. I'm
I have a large validation form that is working very well except for one
I have a large png that I would like to use as a background
Little background: I'm working in a large company with a lot of branches. We
I'm currently working on a large BPM project at work which uses the Global

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.