Need to find all the possible child records with SQL

Hello - I am trying to find a way to solve the following with a sql statement:

I have a table with columns, and the following values:
Trans_Id   Parent_Trans_id
1             null
2             1
3             2
4             3
So basically, 1 is the master parent and I need to bring all ranks, because they are all ultimately originated due to 1. How to write sql code to return all possible levels associated with parent_id = 1?

I hope I'm communicate that effectively do this, but please let me know if it needs to be clarified.

Any help is greatly appreciated...

Thank you
Christine

Hi, Christine.

I think you want to CONNECT BY, something like this:

SELECT     *
FROM     a
START WITH     trans_id      = 1
CONNECT BY     parent_trans_id      = PRIOR trans_id
;

I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.
See the FAQ forum {message identifier: = 9360002}
You will find the answers better faster if you always provide this information whenever you post a question.

Tags: Database

Similar Questions

  • Satellite Pro L40 PSL43E I need to find all the drivers XP

    I need to find all the XP drivers for this laptop in particular. Any ideas where I can find them. on this site, I get only the ' how downgrade "Pease help ASAP.

    If these drivers are available, you will be able to find these drivers on the European driver Toshiba page.

    If the drivers are not available on the European driver Toshiba page, the pilots were not released.

    But I have a suspicion; I found some XP for Sat L40 series drivers. Some series supports the same devices and so the drivers should work also.
    Check some unique XP from different L40 series drivers and maybe he would go.

    Ciao

  • Find all the unique ID associated with a virtual machine

    is there some sort or any command that I could find all the unique ID associated with a virtual machine?

    I mean like ID: ID hardware, CPU ID, UUID, MAC address and etc...

    This should help you

    https://psvmware.WordPress.com/tag/VM-UUID/

  • Find all the possible combinations of grouping

    Hello

    I have a table of color names and must pick up all the possible combinations of color groups. For example, suppose I have the following table: -.
    WITH colours AS (SELECT 1 id, 'red' colour FROM DUAL
                   UNION ALL
                   SELECT 2 id, 'blue' colour FROM DUAL
                   UNION ALL
                   SELECT 3 id, 'green' colour FROM DUAL)
    SELECT *
      FROM colours
    I don't want to get the following results:--
    group  id
    1       1
    2       2
    3       3
    4       1
    4       2
    5       1
    5       3
    6       2
    6       3
    7       1
    7       2
    7       3
    Could someone enlighten me please on how to extract this resultset?

    Published by: tri_harder on April 30, 2010 13:42 updated spelling

    With Oracle 9i:

      1  WITH colours AS
      2       (SELECT 1 ID, 'red' colour FROM DUAL
      3        UNION ALL
      4        SELECT 2 ID, 'blue' colour FROM DUAL
      5        UNION ALL
      6        SELECT 3 ID, 'green' colour FROM DUAL),
      7       m AS
      8       (SELECT COUNT(*) AS max_level
      9         FROM colours)
     10  SELECT   GROUP_ID,
     11           SUBSTR(sp, INSTR(sp, '-', 1, lvl) + 1, INSTR(sp, '-', 1, lvl + 1) - INSTR(sp, '-', 1, lvl) - 1) AS ID
     12      FROM (SELECT     ROWNUM AS GROUP_ID, ID, SYS_CONNECT_BY_PATH(ID, '-') || '-' AS sp
     13                  FROM colours
     14            CONNECT BY ID > PRIOR ID),
     15           (SELECT     LEVEL AS lvl
     16                  FROM m
     17            CONNECT BY LEVEL <= max_level)
     18     WHERE lvl < LENGTH(sp) - LENGTH(REPLACE(sp, '-'))
     19* ORDER BY GROUP_ID, ID
    
      GROUP_ID ID
    ---------- ------------
             1 1
             2 1
             2 2
             3 1
             3 2
             3 3
             4 1
             4 3
             5 2
             6 2
             6 3
             7 3
    

    URS

  • I need to find all of the XML elements and add a line break for the text of each of them

    I need to find all XML elements and to add a line break the text of each of them.

    Is it possible with a script?

    Try this piece of code as it is. I hope that's what you want...

    var myDoc = app.activeDocument;
    var inddRooElement = myDoc.xmlElements.item(0);
    var xPathElements = inddRooElement.evaluateXPathExpression("//*");
    var elementCount = xPathElements.length;
    for(var eId=0; eId
    

    ----------------

    Green4ever

  • How is possible to create a smart collection to find all the photos that are not belongs to any collection?

    Hello

    How is possible to create a Smart Collection to find all the photos are not belongs to any collection?

    "Yesterday I was importing a lot of photo when my camera battery died then I succeeded him and continued to import without thinking that the previous import collection literally means" previous import. "

    So I need to find a way to create a smart collection that will reveal all the photos that do not belong to any collection.

    I solved the problem with a workaround is creating a collection based on the date of the photo which worked well, but must be nice to have a more general collection to find all the photo that are not from the collections.

    Thanks in advance,

    Marco.

    Another way to do

    1. Select all photos in the catalog

    2 dismiss a color label

    3. go to collections and multi select all your collections (ctrl)

    4. select images and give them a color

    5. return to the catalogue

    6. filter by color label - No

  • I tried a trial version of lightroom 6 and edited hundreds of photots I need to find the export files are small non-printable, about 600 kbs. So I bought lightroom 6 hoping to save my changes on all the photos. However with my purchase of more than a week

    I tried a trial version of lightroom 6 and edited hundreds of photots I need to find the export files are small non-printable, about 600 kbs. So I bought lightroom 6 hoping to save my changes on all the photos. However with my purchase of more than a week, my picture exports are still about 600 kbs. Not printable! I'm signed and registered. Whats happening?

    Looks like you have been in the library module and chose with a preset export or export to email. Whatever it is, your Presets 'export' were to reduce the size of the image exported to about 600 k.

    In Lightroom, the library module and under the file menu, simply select the Word Export. Who will open another dialog box. GO through each option in this dialog box to choose where you want to export the file, what color space to use, what name to give to each folder, what metadata to include and do not forget to select the export size! I included a few screenshots for your reference.

    If you export exactly the same path several times, you can create your own export preset to make this process faster.

  • Firefox prompts to save passwords of websites. The key to the Password Manager icon appears on the left side of the address bar, but the corresponding window asking if I want to save the password or not, does not appear. I tried all the possible solutions

    I installed the latest version of Firefox on my laptop (Windows 7 Professional 64-bit). The thing is that firefox prompt to save passwords of websites. I'll explain you a little more away with an example: suppose I load www.gmail.com. When I login, the password manager key is displayed on the left side of the address bar, but the corresponding window which would ask if I want to save the password or not, does not appear. I tried all the possible solutions. It is true that when I restart firefox with disabled modules (safe mode), password manager works fine. But I don't really use Add-ons that could prevent firefox to save passwords. I disabled all add-ons and ran firefox in normal mode, but the password manager does not work yet. Please keep in mind that I tried everything and that any post not published so far describes a similar problem to mine case. Consider that I have the same I have configured the entire system from the beginning. The problem appeared again from the first time I launched firefox. At that time, I had not installed any antivirus software and there is no add-on with firefox. Hope someone can give me a valid solution...

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > appearance/themes).

    It is possible that there is a problem with key3db and signons.sqlite files that store the encrypted names and passwords in Firefox.

    Rename signons3.txt and signons.sqlite files in the Firefox profile folder.

    You can add .old files (key3.db.old and signons.sqlite.old) names or move them to another folder to make it possible to cancel the action.

    You must define a new master password after renaming or removing the signons3.txt and all the currently saved passwords are lost.

    If that worked, then you can delete the renamed files that are no longer needed.

    See:

  • Where can I find all the drivers Win 7 for Satellite L40 - 14F

    Hi all
    Find all the drivers for L40 laptop model 14F for windows 7 OS? Is that someone has installed this OS? Is it possible to have some problems during installation? Thank you very much.

    Most of the new models is Win8 or Win10 models, they won't get Win7 drivers available.

  • How to find all the Subvi value changes to a control inside a cluster?

    I have a question I've had brewing for many years now, and as of today, this issue has become less philosophical for me now that I have a VI project with hundreds of screws in there to work through... If I have a cluster which is passed between/through several subVIs, is there a way to find all reads/writes to a particular control within this cluster? For example, if I use a global variable, I can find all the instances where this variable has been changed. Several times, a cluster is used to pass data instead of lots of global variables, but I know not anyway quickly find where specific parts of the latter are read or written in subVIs. Global variables becomes a headache when they are too many of them fly around, but I can't keep track of reads/writes in bunches without manually looking through a few screws hundreds that take in the cluster. Is there a function for this that I'm not aware of? I hope that this question/problem of logic. This may prompt a discussion of architecture, which I would be happy, because I will need to build projects of this scale in the future, but I think also completely stuck when the clusters are used (by me or others) to pass data autour. Thank you! John

    If you ungroup by name and bundle by name, just do a search for text to the name of the control.

  • HP Pavilion n072sy-15 Notebook PC - where to find all the drivers for Windows XP and Windows 7

    Who knows where to find all the drivers for Windows XP and Windows 7 for HP Pavilion n072sy-15 Notebook PC?

    Hello:

    XP will not install or run on a PC with an Intel 8 series chipset, so you need not be concerned with finding drivers.

    Here is the link to a template that you can use the W7 x 64 bit drivers from.

    When you install the graphics drivers, first install the Intel HD graphics driver, reboot and then install the graphics driver nVidia.

    DO NOT USE ALL DOWNLOADS OF BIOS OR FIRMWARE FROM THIS LINK

    http://h10025.www1.HP.com/ewfrf/wc/softwareCategory?OS=4063&LC=en&cc=us&DLC=en&sw_lang=&product=6521374

  • I have all the Adobe Creative Suite with all the programs installed on my mac, I bought a new mac and go to sell the need for others, but I have to get the programs on the new computer and I also lost the serial number for it, what can I do about it?

    I have all the Adobe Creative Suite with all the programs installed on my mac, I bought a new mac and go to sell the need for others, but I have to get the programs on the new computer and I also lost the serial number for it, what can I do about it?

    Find the serial number of your Adobe product quickly

  • GREP with lookaround: impossible to find all the "." with the exception of the end of the paragraph

    Hi all

    I'm actually build an expression grep to run in an InDesign document to find all the '. '. (full stop) without any whitespace that follows, except those standing at the end of a paragraph. My approach:

    \. (?! \s) (?! $)

    For some reason any '$' does not work when it is used as a negative lookahead. In the following example, only the first '. ' is found.

    test. test.test.test.

    Not used as anticipation as here...

    \. (?! \s) [^$]


    It works very well. But unfortunately I am I need the search for only the "." is divided as a result.

    I would appreciate any advice.

    Thank you very much!

    Jan

    This grep finds all the "." without space after except the one at the end of the paragraph

    (?<>

  • Find all the lines from the previous column value difference lines

    I have an interesting requirement. There is a DATE column and a user in one table and I have to find all the lines for all users for which the previous and the current line has lagged in lets say more than 30 minutes. The rows are already sorted in time.

    For example in the following table, we need to ID 4 and 6 for user 1.


    Date of the user ID
    1 1 today 1 hr. 0 Min. 0 sec.
    today 2 1 1 hour 1 min 0 sec
    Today 3 1 1 hour 29 min 0 s
    * 4-1 today 1 hour 59 min 3s *.
    5 1 today 2 hours 10 min 2 sec
    * 6 1 today 2 hours 50 min 7 s *.

    Published by: user733179 on March 5, 2009 12:00

    Hello

    To obtain a separate calculation for each value of the usr, start the analytical clause with "BY usr PARTITION":

    WITH     got_dif     AS
    (
         SELECT     id,     dt,     usr
         ,     (dt - LAG (dt)
                    OVER ( PARTITION BY  usr
                              ORDER BY          dt
                            )
              )             -- difference in days
                  * 24 * 60  AS minutes_dif
         FROM     table_x
    --     WHERE     ...     -- if needed
    )
    SELECT     id,     dt,     usr
    FROM     got_dif
    WHERE     minutes_dif     > 30
    ;
    
  • How can I find all the plugins in the firefox browser

    HI I was wondering if I could ask a question how can I find all the installed plugins in the firefox lasted I would like to be able to know if, for example, if the shockwave plugin is updated and which version is currently installed in the firefox browser lasted.

    Thank you

    Hello Funny78, type Subject: addons in the address bar and then select plugins, add-ons manager opens and you can see the last version of the plugins (and other info), now click on the click to see if your plugins are up to date and see if it is.

    Thank you

Maybe you are looking for