How to get the node root for all nodes using oracle SQL?

Suppose I have an employee table, which has the following features:

ID name MgrID
----------------------------------------
1 Tom
Jason 2 1
3 Kelly 2
4 Chris 2
Russ 5 3
--------------------------------------

I want to get the following result.

ID name RootMgrID
------------------------------------------------
1 Tom
Jason 2 1
3 Kelly 1
4 Chris 1
Russ 5 1
-----------------------------------------------

How can I get it?

Thank you very much

Like this?

SQL> with t as
  2  (select 1 id, 'Tom ' name, null mgr_id from dual
  3  union all
  4  select 2 id, 'Jason' name, 1 mgr_id from dual
  5  union all
  6  select 3 , 'Kelly ', 2 from dual
  7  union all
  8  select 4 , 'Chris ', 2 from dual
  9  union all
 10  select 5 , 'Russ ', 3 from dual
 11  )
 12  select id, name, connect_by_root(id)
 13  from t
 14  where name = 'Russ '
 15  connect by mgr_id = prior id
 16  start with id = 1
 17  /

        ID NAME   CONNECT_BY_ROOT(ID)
---------- ------ -------------------
         5 Russ                     1

SQL>

Tags: Database

Similar Questions

  • How to change the password of a schema by using Oracle SQL Developer

    Hi need to change the password of a schema by using Oracle SQL Developer, how can I do?

    or maybe http://www.thatjeffsmith.com/archive/2012/11/resetting-your-oracle-user-password-with-sql-developer/

  • How to get the code produced for my Windows XP disc if I have the drive?

    Acquisition of Product Code Windows XP

    How to get the code produced for my Windows XP disc if I have the drive?  I signed the BONE when I bought it all first, but have no way of knowing if this is the way to receive a copy of the product key.

    Here are some utilities, which will display your product keys:

    Belarc Advisor: http://www.belarc.com/free_download.html
    (He did a good job of providing a wealth of information.
    However may not detect a key to office, then try one of the other two below)

    Also: http://www.nirsoft.net/utils/product_cd_key_viewer.html
    and: http://www.magicaljellybean.com/keyfinder.shtml

    Paid (free demo is available): Recover Keys: http://recover-keys.com/
    "quickly scans your system for more than 3000 + software '.
    and produces a list of software activation keys.

    13 keyfinder programs:
    http://pcsupport.about.com/od/productkeysactivation/TP/topkeyfinder.htm

    J W Stuart: http://www.pagestart.com

  • I made my largest site and how can keep the same size for all other sites?

    I did the 2 larger site and how to keep the same size for all pages when I re - open the web browser?

    You can use an extension to set a page zoom and the size of the default font on the web pages.

  • How to get the device model, for example app works on PlayBoook or BlackBerry 10?

    How to get the device model, for example app works on PlayBoook or BlackBerry 10?

    You can use this class: http://goo.gl/GtMLP for information on devices

    something like this:

    String myDeviceModel = android.os.Build.MODEL;
    String myDeviceBrand = android.os.Build.BRAND;
    String myDeviceDevice = android.os.Build.DEVICE;
    
  • How to get the message to debug all to running page request OFA?

    Hello

    How to get the message to debug all to running page request OFA? do not use JDeveloper

    Thank you

    Renon,

    this.writeDiagnostics will be work AM and not CO. You mentioned that your code is AM, which is why I give (this.writeDiagnostics).

    You get an error when you use what to ? AM

    in CO, you must use pageContext. writeDiagnostics();

    You don't need to put any profile (other than DNF: Diagnostics), you just need to go to the Diagnostics - select the log on screen and choose the level that you used in the writeDiagnostics method.

    See you soon

    AJ

  • How to check the table have are all views in oracle

    Hello
    How to check the table have are all views in oracle
    SELECT * FROM user_dependencies
    WHERE type='VIEW'
    AND referenced_type='TABLE'
    AND referenced_name ='Your_Table_Name' 
    

    You can use dba_dependencies to find views in the different schema.

  • How to get the default border for TextField?

    In my textfields entry UI, I have them red border if the user enters invalid data. However, I need to reset the border to how it was.

    field.setStyle("-fx-border-color: gray;");
    

    It does not have the default border on windows XP (JavaFX2.2.21)

    The default border is rounded and lightgray.

    I also tried without success

    field.setStyle ("border - fx - color: null;" "");

    - and/or border - color: null; ») ; r color: gray; »

    The style sheet by default (in Java 7), caspian.css, is not actually apply a border to the text field at all but use layered backgrounds of different radii for the border effect.

    The best way to achieve the desired effect is to add and remove a style from the text box class and set the border color in an external style sheet. However, you should be aware of the https://javafx-jira.kenai.com/browse/RT-23085. One solution is to define a border radius default of zero on the text field and a different RADIUS to your "custom" css class Given that the default style sheet does not have a border that won't break anything.

    Example:

    import java.util.regex.Pattern;
    
    import javafx.application.Application;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.scene.Scene;
    import javafx.scene.control.TextField;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    
    public class ErrorTextFieldTest extends Application {
    
     @Override
      public void start(Stage primaryStage) {
      final VBox root = new VBox();
      final TextField textField = new TextField();
      root.getChildren().addAll(textField);
    
      final Pattern intPattern = Pattern.compile("-?[1-9]\\d*");
      final String errorCSSClass = "error" ;
      textField.textProperty().addListener(new ChangeListener() {
          @Override
          public void changed(ObservableValue observable,
              String oldValue, String newValue) {
            if (newValue.length()==0 || intPattern.matcher(newValue).matches()) {
              textField.getStyleClass().remove(errorCSSClass);
            } else if (! textField.getStyleClass().contains(errorCSSClass)) {
              textField.getStyleClass().add(errorCSSClass);
            }
            System.out.println(textField.getStyleClass());
          }
        });
    
      Scene scene = new Scene(root, 200, 100);
      scene.getStylesheets().add(getClass().getResource("errorTextField.css").toExternalForm());
      primaryStage.setScene(scene);
      primaryStage.show();
      }
    
      public static void main(String[] args) {
      launch(args);
      }
    }
    

    errorTextField.css:

    @CHARSET "US-ASCII";
    .text-field.error {
     -fx-border-color: red ;
      -fx-border-width: 2px ;
    }
    .text-field {
     -fx-border-width: 0px ;
    }
    

    (Note: there is no space in ".text - field.error".)

  • Satellite L500-154 - how to get the software packaged for Win7

    How can I get the software "Bundled" for Win 7, I will install Win 7 full (no updates), in the moment is runing Vista on the laptop

    As far as I know, you can't have Win7 recovery media. Laptops ship with Vista can update only.

  • How to get the new update for the help and support

    OT:how to get the new update of the abd support help

    How to get help and support update

    Hello rickstemberger,

    Please click the number of the KB article for more information on how to add Windows Vista Help files.
    KB Article ID: 917607 -I can not open Help files that require the Windows Help program (WinHlp32.exe)

    Microsoft stopped including the 32-bit help files viewer in versions of Windows starting with Windows Vista and Windows Server 2008.
    However, with article 917607, you can download the appropriate version of the Windows Help program (WinHlp32.exe) and add them
    the operating system.

    Sincerely,

    Marilyn
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • How to get the latest fix for CPU

    Hi gurus,

    Hello.


    How to get the latest information from CPU fix for our system EBS 11i, how to get alerts whenever they have released patches of CPU.

    Hi DBA.

    Please check this, hope this helps.

    See the metaink notes:

    Releases of Oracle E-Business Suite 11i and 12 Critical Patch Update knowledge Document (October 2010) [ID 987438.1]

    Information OCT - 2010 CPU patches:

    http://www.Oracle.com/technetwork/topics/security/cpuoct2010-175626.html

    on the paths of the CPU:

    http://www.Oracle.com/technetwork/topics/security/alerts-086861.html

    For the email subscription:

    http://www.Oracle.com/technetwork/topics/security/securityemail-090378.html

    Published by: Amigo on December 22, 2010 07:26

    Published by: Amigo on December 22, 2010 07:29

  • [ADF, JDev12.1.3] How to change the font size for all of the components of output within an af:panelBox?

    Hallo,

    I need to change the font size for all the inputTexts, LOVs of outputText, labels, etc. which are in different panelFormLayouts inside a panelBox.

    I tried to define a CSS class and to assign to the panelBox but it has not worked.

    You kindly suggest me an easy way to do this?

    Thank you

    Federico

    Hello

    You can try something like this:

    AF | panelBox::content label, af | panelBox::content, af | panelBox::content entry, af | panelBox::content select {}

    your style

    }

    At least the style of the components you named should be changed. If you need more you can add others.

    Kind regards

    Ruben.

  • How to get the free license for VMware vSphere Hypervisor 5?

    Please show me the link where I can get the free license for VMware vSphere key 5?

    Connect the link with the register username and password below.

    https://www.VMware.com/tryvmware/index.php?p=free-esxi5&LP=default

    Click on licenses and download tab... you will see the license key.

  • How to get the script to a table or view in SQL Developer?

    Dear friends/expert,

    Could you tell me how to get the script from a view or a table easily in SQL Developer as pressing F4 in TOAD?

    I found that I can press SHIFT + F4 to view in SQL Developer and get the script of the view in the Details tab. But how to move the script to the SQL worksheet to change? It is very easy to do in TOAD.

    And I have not found a way to get the script for a table up to now. Is it possible to do?

    Thanks in advance.

    Best regards
    Ning

    There are people a lot better out there to answer on this point than I am - but here's how I do it.

    I'm just in the browser/browser for interest table, choose the script on the right side tab (which shows all the SQL for the table) and then cut and paste what I want or need in my editor window.

  • HP laser jet 3030 how to get an email Id for this print using eprint

    How to get an email ID for jet Laser HP 3030 to use eprint

    This isn't a matter of comercial, I Chron. Hp and I have Hp laser Jet 3030 printer how to connect the two

    Please aadvice

    Raymond [redacted for privacy] Canada

  • How to get the IP address, Port database don't & Oracle SID details

    Hello
    How to know the IP address, Port database don't & Oracle SID details

    Hello

    The IP address is for not for the database server.

    Port no, may be different.

    check what sid, listening to the port

    lsnrctl > status

    or

    Open the tnsname.ora or listener.ora to find what hostname(ip address), what is the port number and what is the SID that you connect

    Hope that answers your question.

    Kind regards
    Rakesh Jayappa

Maybe you are looking for

  • Can I send a photo of smaller size in Outlook Express?

    Outlook Express gives me the ability to send a picture file full size or one size smaller. It is possible to do this with Thunderbird?

  • dc7900 sff: Quadro nvs 290 in dc7900

    Hello in my dc7900 SFF and I don't have a chance. I followed these instructions without result. "When a PCIeX16 graphics card is installed in the PCI onboard VGA connector black"and display ports will be disabled automatically." What was happening is

  • Sony VAIO PCV-RZ46G

    I bought a Sony VAIO PCV - 46G on Ebay opportunity.  I was told that the hardware and the software has been configured initially purchased.  At the reception of the device, I found that it would not start and the hard drive has been replaced.  He had

  • Xperia Z2 video without sound

    Hello My z2 is abour age of 4 weeks. Evey Software and Android is the latest version. the first days I was able to record videos with sound. 3 weeks later, I tried again on great moments in my live and when I went to see the video, the video plays wi

  • No response from the seller ID number of package support

    Hi all Anyone fron blackberry can help me on this problem. On March 30, I applied for the support of the seller to change the package ID. March 31, I got the answer of the global team blackberry on the change of package IDS. On April 2, I sent the em