How to find a point of intersection between two paths in the hierarchy? (2 G 11)

Hi all!

I need your help to write a hierarchical query.

Suppose that we have a table hierarchycal as

WITH h AS (SELECT 0 AS rn, to_number(NULL) AS prn, 'root' AS point_name   FROM dual
UNION SELECT 1 AS rn, 0 AS prn, 'a' AS point_name  FROM dual
UNION SELECT 2 AS rn, 1 AS prn, 'b' AS point_name  FROM dual
UNION SELECT 3 AS rn, 1 AS prn, 'c' AS point_name  FROM dual
UNION SELECT 4 AS rn, 2 AS prn, 'd' AS point_name  FROM dual
UNION SELECT 5 AS rn, 3 AS prn, 'e' AS point_name  FROM dual
UNION SELECT 6 AS rn, 2 AS prn, 'f' AS point_name  FROM dual
UNION SELECT 7 AS rn, 3 AS prn, 'g' AS point_name  FROM dual
UNION SELECT 8 AS rn, 6 AS prn, 'h' AS point_name  FROM dual
UNION SELECT 9 AS rn, 5 AS prn, 'i' AS point_name  FROM dual
UNION SELECT 10 AS rn, 7 AS prn, 'j' AS point_name  FROM dual
UNION SELECT 11 AS rn, 10 AS prn, 'k' AS point_name  FROM dual)
SELECT h.* 
FROM h 
CONNECT BY PRIOR h.rn=h.prn
START WITH h.prn IS NULL

I chose a single line, with rn = 11 for example, as a "starting point." After that I need to select one or more rows in this table under certain conditions. Whether rn = 8 and 9, for example. By the same query, to the next step, for each point that I chose by condition, I need to calculate, how far is it to the "starting point".

I think, I need to find a point of intersection of the path from the root to the selected point along the same path of the "starting point". By comparing this tip I'll can understand which of them is closer to the "start".

The only thing that I have arrived, it's trying to compare the results of sys_connect_by_path...

Hello

This indicates to what extent each of the nodes 'interest' are from the node of "start":

WITH connect_by_results AS

(

SELECT CONNECT_BY_ROOT rn: the NURSE

CONNECT_BY_ROOT SUBSTR (point_name,

1

8

) AS node_type

rn AS ancestor

LEVEL AS lvl

H

START WITH point_name = 'start '.

OR point_name LIKE '% interest '.

Rn = prn PRIOR CONNECTION

)

SELECT i.rn

, MIN (i.lvl + s.lvl) - 2 AS distance

Connect_by_results I have

JOIN connect_by_results s ON s.ancestor = i.ancestor

WHERE s.node_type = 'start '.

AND i.node_type = 'interest '.

GROUP BY i.rn

ORDER BY i.rn

;

Exit: (from your sample data, where 11 is the starting node):

DISTANCE OF RN

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

8        7

9        5

14 3

Tags: Database

Similar Questions

  • No overlap between two paths - "crossing the border" - how?

    I have two paths, and I want them to be exact in a single line.

    twopaths.png

    I tried to do it by hand, but this not true - there is an area of overlap between the two railways. How can I change this?

    It is perhaps difficult to explain. So here's another test: it should look like a country, each country has its border - the border to cross to the other country. No non-mans land. It works perfectly with a vector point - when you create a new one on an existing, he said "anchor". I want the same service here for this "border".

    Thanks in advance for any help!

    You could duplicate the existing path segment.

    But in fact it's just easier simply to draw the map with a single path for each border and then fill the shapes using the direct shapebuilder or paint tool.

  • Point of intersection between the line interpolated in Grapher

    How to find the point of intersection between interpolated lines using points offered as input to a file in grapher comps?

    What version of Mac OS X?

  • I subscribe to ICloud Creative pour a team of 2 people.  I was paying $ 114.95, taxes included. For two months, I pay $ 160,94 USD.  How to find l, subscription I had? can I make the change directly from my account?... .o

    I subscribe to ICloud Creative pour a team of 2 people.  I was paying $ 114.95, taxes included. For two months, I pay $ 160,94 USD.  How to find l, subscription I had? can I make the change directly from my account?... General do I contact Adobe?

    It's probably the passage of the special offer that lasts a full pot of for the price of one.

  • Delay between two operations in the same visa write buffer

    Hello

    I'm new to labview and have tried to find a way to introduce some delay in milliseconds between two operations in the same buffer of writing a block of single entry visa. Here's what I want it to be like:

    CURR: LEV 1.5

    wait about 50 ms

    CURR: LEV 2.0

    wait once again

    In fact, I must apply an alternating signal to a coil with a certain frequency through a source of supply of power e3631a Agilent. So if there is another alternative for her, so please let me know.

    Thank you

    Concerning

    Here are two approaches. First being the easiest, simply put a delay between written VISA. The second being a more robust because it allows you to develop a series of commands by simply adding the string array. You might forget the case of the loop if you don't mind the 50mS delay before e first command is sent.

  • line set between two icons on the toolbar.

    Hi all


    How to create the line between two icons on the toolbar? help out me thanks in adavnce.



    Sarah

    Hi Sarah!

    You can't create a separator menu item in the top menu.
    Create a submenu and put all your toolbar menu item.
    Between the items that you want to have a line, create a sepatator menu item
    Properties: Visible in the menu: No. and visible in the menu bar horizontal: Yes.

    Concerning

  • Because between two keyframes with the same position, there is movement?

    Because between two keyframes with the same position, there is movement?

    This would be due to the influence or speed?

    Quick glance:

    1. image: 'x' is 384px

    Capturar.PNG

    2 image: 'x' is 387px

    Capturar_2.PNG

    3. picture: 'x' is 384px

    Capturar_3.PNG

    Keyframes to which I refer are selected in the middle.

    Photo.PNG

    There is a change in the balance between two key frames that are in the same position, without keyframes between them.

    FAQ: Why my layer (camera) moves backward between the keyframes value equal?

  • How to calculate if an object is between two points

    Okay so I'm an RTS game, and ive got my participants

    displacement = false;

    CheckIt = false;

    startPt = {};

    Start = {};

    var i = 0;

    Fill._alpha = 0.1;

    onMouseDown = function() {}

    move = true;

    startPt.x = _xmouse;

    startPt.y = _ymouse;

    }

    onMouseUp = function() {}

    displacement = false;

    CheckIt = true;

    endPt.x = _xmouse;

    endPt.y = _ymouse;

    square_mc var = this.createEmptyMovieClip ("" + i, i ++);

    square_mc.beginFill (Fill);

    square_mc. MoveTo (startPt.x, startPt.y);

    square_mc. LineStyle (4, 00000000, 50);

    square_mc. LineTo (_root._xmouse, startPt.y);

    square_mc. LineTo (_root._xmouse, _root._ymouse);

    square_mc. LineTo (startPt.x, _root._ymouse);

    square_mc. LineTo (startPt.x, startPt.y);

    square_mc.endFill ();

    square_mc = null;

    }

    onEnterFrame = function() {}

    If (! dragging and checkit) {}

    scroll through the objects and see if they are with startPt, endPt

    CheckIt = false;

    }

    }

    And I want to check if my workers are between the two points (well 4) of:

    startPt.x

    startPt.y

    endPt.x

    endPt.y

    Ive tried this

    If (_root.workers [i] ._x > startPt.x & & _root.workers [i] ._y > startPt.y & & _root.workers [i] ._x > endPt.x & & _root.workers [i] ._y > endPt.y | _root.workers [i] ._x < startPt.x & & _root.workers [i] ._y < startPt.y & & _root.workers [i] ._x > endPt.x & & _root.workers [i] ._y > endPt.y) {}

    workers [i]. Selected = true;

    Workers [i] .gotoFunction ();

    }

    But I don't think that it's actually calculate if the worker [i] is between these points.

    so could someone please tell me how to calculate if my work is between these points, so I could do then selectable

    Thanks in advance

    I don't think you have this conditional is to check what you're saying, you want to check... try...

    If (_root.workers [i] ._x > startPt.x & _root.workers [i] ._y > startPt.y & _root.workers [i] ._x)< endpt.x="" &&="" _root.workers[i]._y=""><>

  • How to find the difference between two dates in the presentation layer

    Hi gurus,

    Hello to everyone. Today, I came with the new requirement.


    I need to know the difference between a date and the current date in the formula column application presentation layer.by.



    Thank you and best regards,
    Prates

    Hi Navin,

    TIMESTAMPDIFF function first determines the timestamp component that corresponds to the specified interval setting. For example, SQL_TSI_DAY corresponds to the day component and SQL_TSI_MONTH corresponds to the component "month".

    If you want to display the difference between two dates in days using SQL_TSI_DAY, unlike butterflies SQL_TSI_MONTH and so on...

    hope you understand...

    Award points and to close the debate, if your question is answered.

    See you soon,.
    Aravind

  • How can I set sharing of files between two iMacs?

    I want to set up the sharing of files between two iMacs in my office. Both work on iOS 10.11.3 and both are on the same WiFi network. I'll Finder, select the name of the other computer under 'sharing', then ' connect under... ". ", and then enter the name and password of the other computer. On a computer, I am told that it is connected with each other. However, the second computer always shows "the connection failed". I tried the 'Registered user' choice of "Guest" and "using Apple ID", but none will establish the connection. There must be something obvious that I'm missing, but I wasn't able to find out. I also tried to see if they would communicate with Bluetooth. Bluetooth screens on each computer show the the other is detectable by the proper name, but is never establish a connection.

    Connect to the same network.

    Enable sharing of files on both machines.

    Select the items to share on each machine and check the box in the dialog box information.

  • How to send and receive text messages between two simulators?

    I launched the first Simulator by inputing D:\Program Files\Eclipse\plugins\net.rim.eide.componentpack4.5.0_4.5.0.16 «»
    ents\simulator > 8300.bat/sms-source-port = 5000/sms-destination-port = 5001 "cmd

    tnen second Simulator by inputing E:\simulator>8300.bat/sms-source-port = 5001/sms-destination-port = 5000 in cmd

    but I can't not Simulator send and receive sms

    I assume that you have followed all of these steps?

    How - send SMS text messages between two BlackBerry Smartphone simulators

    http://www.BlackBerry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800792/801083/How_To _...

    Can you elaborate on what does not work?  You see errors?  When missing to?

  • Balance sheet for a YEAR between two dates in the dashboard

    Hello

    Could someone help me please how can I calculate the 'balance of the CDA' between two different dates, who is invited to the dashboard? Means: we have an "effective date" and a "prior date" as a promt in the dashboard user who selects dynamically. When displaying in the report, it should show us the "CDA balance" between the two dates selected dynamically by users in the dashbowrd prompt. Please suggest.

    Thanking you,
    BK.

    Now that you understand the concept, it is easy to change the constant (i.e., 2011-01-01) to a variable.

    1) start with your repository variable that contains your current date: CURRENT_DATE

    (2) TIMESTAMPADD (SQL_TSI_DAY, DAYOFYEAR (CURRENT_DATE) *-1 + 1, CURRENT_DATE) is the SQL to get the first day of the year.

    Replace the hardcoded hard 01/01/2011 with the SQL above and now it will work for the beginning of the current year. You can change the SQL code for the beginning of a given year.

    Ex. TIMESTAMPADD (SQL_TSI_YEAR-1, TIMESTAMPADD (SQL_TSI_DAY, DAYOFYEAR (CURRENT_DATE) *-1 + 1, CURRENT_DATE)) you will get the start of "last year." This should help you with your problem.

    Now that you have everything, please mark the appropriate messages 'useful' and 'proper' and then mark the thread as answered and others if you are looking for a similar solution can easily find the answer. Thanks and good luck!

    Edited by: David_T November 28, 2011 07:56

  • I'm having a problem with a transition between two clips in the first.

    I put a transition between two clips, but it works only in a single clip. my project is almost done except to fix those errors.

    problem.jpg

    The handles are how you have before and after the section of the video images you removed in the timeline.

    Imagine you put a video in your editing and you use the clip (from the beginning to the end). Then you try and add a second 2 cross dissolve between the shots. First will have to at least 1 second image to prior to the shooting to make the transition, but because that there are no images more to use is unable to dissolve it in the middle of the Cup.

    You can do it all on a track just like FCP of Vegas, but you must have the images it to dissolve in.

  • Why don't I have a green exclamation point on one of my vi in the hierarchy of VI?

    Hi seafood

    Stay of execution


    Suspend execution of a Subvi to change the values of
    controls and indicators, to control the number of times that the Subvi is running
    before you return to the caller, or return to the beginning of the
    the Subvi execution. You can get all calls to a Subvi
    with the suspended, or you can suspend a specific call to a Subvi.

    To suspend all calls a slot - VI, open the Subvi and select Operate"
    Suspend when it is called
    .
    The Subvi suspends automatically when another VI calls it. If you
    Select this option when single-no, the Subvi does not suspend
    immediately. The Subvi suspended when it is called.

    To end a call specific Subvi, click the Subvi on the block schema node, and then select node Subvi
    The installation program
    in the context menu. Check the suspend when it is called to suspend enforcement only to this instance of the Subvi.

    "The window of the Hierarchy of VI , which view you by selecting view" VI hierarchy.
    indicates if a VI is interrupted or suspended. An arrow glyph, shown as
    as a result, indicates a VI runs regularly or not not unique.

    A glyph break, shown below, indicates a VI interrupted or suspended.

    A green break glyph, or a hollow glyph in black and
    White, shows a VI that stops when it is called. A glyph of Red break, or a
    Glyph of solid black and white, shows a VI that is currently
    pause. A glyph of exclamation point, shown below, indicates that
    the Subvi is suspended.

    A VI can be suspended and stopped at the same time.

    Determination of the current Instance of a Subvi


    When you hold a Subvi, calls list
    pull down menu in the toolbar list the chain of callers of the
    first level VI down to the Subvi. This list is not the same list you see
    "When you select go" callers to this VI, which lists asking them all screws regardless of whether they are running. Use call list
    menu to determine the current instance of the Subvi if block
    diagram contains multiple instances. When you select a VI in the menu calls list , its block diagram opens, and LabVIEW highlights the current instance of the Subvi.

    content above http://zone.ni.com/reference/en-XX/help/371361B-01/lvconcepts/debug_techniques/

  • calculations between two values of the sequential loop iterations

    Hi all

    I have a code that came out our power (DSP) of a FFT spectral density. An input frequency and then intervened at a value of input from the user. I would like to know the difference of the PSD between each stage of the frequency. Attached, that's what I would get. To avoid confusion, I don't want to produce a file that looks like this. I want just the column 'delta' as an indicator on the front panel, so I can control my change in PSD. I don't need the entire table, just the delta between the current iteration and the previous iteration. I tried to use a loop with shift registers, but I'm not sure where to go to from there. I thought that, since the shift registers sends the data of loop to loop, that I could output the value before it went into the next iteration, but I don't have a chance. Any help is appreciated. Unfortunately, I am unable to put the code due to the policy of the company. I know it makes things much more difficult.

    Thank you.

    Suggestions do not seem quite right, but I found a way to do it. Attached, is the way that I did.

Maybe you are looking for

  • How can I create a filter to remove only "junk" from the server?

    One of my email accounts is an important customer. I manage their online customer service. Normally our protocol must always leave all messages on the server, so that one Thunderbird account, I never put delete messages on the server. But the account

  • Driver for windows 7

    Hi, I bought the Hp Pavilion g7-2210sm today and I have installed windows 7 and now I have a problem with the drivers. I can't find windows 7 drivers for this laptop. Please help me and sorry for the bad English, I'm from the Serbia and maybe I made

  • The Microsoft event and logmein123 scam.

    I was scammed of Microsoft events and gave them access to the computer. What should I do? My computer is now at risk? What happened to all my passwords online banking and other. They phone call came from a man very Indian survey.

  • How to install drivers for "Dell adapter - USB 3.0-HDMI/VGA/Ethernet/USB 2.0"?

    I bought the Dell XPS 13, and I need an adapter to connect to Ethernet: Dell adapter - USB 2.0 3.0-HDMI/VGA/Ethernet/USB. - How to install this driver? -Will I install it on my "gold statue? I cannot join the domain because Windows Setup cannot find

  • BlackBerry Smartphones access to files on memory card

    Hello I want to pass the ringphones of phone to my computer. But I don't have access to the memory card and usb cable. Is there a program, which allows me to access the memory card? I thanks for your help... concerning Student2