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 8493649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:04:44+00:00 2026-06-10T23:04:44+00:00

I have a table TABA(PK:NAME) that stores NAME,NAME_TYPE,SOURCE this way: NAME NAME_TYPE SOURCE —-

  • 0

I have a table TABA(PK:NAME) that stores NAME,NAME_TYPE,SOURCE this way:

NAME  NAME_TYPE SOURCE
----  --------- ------
Name1 Category  S1
Name2 Category  S2
Name3 Datamart  
Name4 Category  S1
Name5 Datamart
Name6 Datamart
Name7 Category  S3

Note above: Only if the NAME_TYPE = Category, then the source is present in the data.

I have another table TABA_PARENT that stores NAME,PARENT_NAME with the relationship between the NAME columns based on the name_type this way.
Datamart to Category relationship is one-to-many.

  NAME   PARENT_NAME
    -----  -----------
    Name3  Name1
    Name3  Name2
    Name3  Name4
    Name3  Name5
    Name5  Name1
    Name5  Name6
    Name6  Name7

My requirement is to get the SOURCE for TABA where NAME_TYPE = Datamart(currently, it is absent in TABA)

Expected Output:

SOURCE column for Name3
-----------------------

S1,S2,S3

The trick is to recursively deduce the SOURCE for the Name3 until it maps to a Category in TABA_PARENT.

In the above example:

Name3 is mapped to PARENT_NAME Name1,Name2,Name4,Name5.
3 of these(name1,Name2,Name4) are of name_type = Category and hence the distinct source is available in TABA — S1,S2
The fourth PARENT_NAME Name5 is a name_type Datamart(source info not available) and needs to be further expanded until it reaches name_type = Category.

We have the information that Name5 is mapped to PARENT_NAME Name1,Name6.
Name1 is a Category and hence source can be deduced.
Name6 is again a Datamart.

But, Name6 ultimately is mapped to Name7 which is a Category, hence source is available — S3

As shown above, all the mappings have to be recursively resolved until they reach name_type Category to identify the distinct sources.

Expected Result: S1,S2,S3 

I am trying if this can be done using listagg or something similar(small pl/sql code would also be ok, but prefer a sinlge select if possible)
I am having difficulty to recursively do this.
Any help would be much appreciated.

  • 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-10T23:04:46+00:00Added an answer on June 10, 2026 at 11:04 pm

    Thanks for anyone attempting this.
    I tried to use a combination of “connect by” and listagg and achieved the desired result.

    select listagg(source,',') within group (order by source) final_source from ( 
    select
    distinct
    b.source source--,
    from taba_parent a, taba b
    where b.name = a.parent_name
    and b.name_type = 'Category'
    connect by prior a.parent_name = a.name
    start with a.name = 'Name3'        
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table Players with columns: ID Name Points What is most efficient way
I have table in an MS Access database that looks like this: ID Symbol
I have a table that contains an xml document stored as a clob. TabA
I have table with around 70 000 rows. There is 6000 rows that i
I have table and this table contain result column with some entries. I just
I have table with 300 000 records (MyISAM). I get record from this table
I have table of data that is sorted as follows: Item | Sample |
I have table with column Percentage varchar(10) Data in that table is Pecentage 2/10
I have table with two columns (varchar from, varchar to). This table represents connections
I have table with 5 columns ------------------------------------------------------ |_id(mongo default)| link | name| street|zip |

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.