How to count the tree levels?

Hi..
I'm a new memeber here.. and I have a problem :S
My problem is about counting the maximum number of a tree levels.
the question was: write a methode that receives a root of a binary tree and returns the maximum number of levels it has.
I wrote the following methodes:
public void depth() {
System.out.print(depthHelper(root));
private int depthHelper(TreeNode node) {
int level = 1;
if (node == null) {
return 0;
level = level + depthHelper(node.rightNode);
return level;
The problem is that these methodes count levels from one side which is the right side or left side if I wrote "node.leftNode".
SO, how can I count them from both sides?
I'll be very glad if you help me.

It's often best to start with standard recursive tree traversal algoritm,
private dH(TreeNode node) {
   if (node != null) {
      dH(node.leftNode);
      dH(node.rightNode);
}You must keep track of the current depth and the maximum depth so far. The current depth is easy. You just increment it each time you go deeper.
private dH(TreeNode node, int current) {
   if (node != null) {
      dH(node.leftNode, current + 1);
      dH(node.rightNode, current + 1);
}The maximum depth is global to the tree so you should keep it outside the method. In each recursive step you compare it to the current depth
int maximum = 0;
private dH(TreeNode node, int current) {
   if (node != null) {
      if (current > maximum)
         maximum = current;
      dH(node.leftNode, current + 1);
      dH(node.rightNode, current + 1);
}Now maximum contains the maximum depth.

Similar Messages

  • How to count the number of rows in a resultser object?

    hi there
    how to count the number of rows in a resultser object which may contains millions of rows? besides using a while loop? thanks

    You don't, you execute a query whose result is the record count of those records that match the search and then you execute the actual query to create your record set. Typically you do
    select count(id) from YourTable where [filter]
    from the resulting ResultSet do
    int res.getInt(1);
    which gives you the count and then
    select id from YourTable where [filter]
    to produce the actual result set.
    in the second query the id part can be substituted with the actual fields you want.

  • How to change the source level in java Studio creator

    Hi,
    I am using Sun Java Studio Creator 2 Update 1 IDE, in this IDE how to change the source level to 1.5 for an existing project.
    Thanks in advance,
    Rajesh.

    Hi!
    Unfortunately Sun Java Studio Creator 2 Update 1 doesn't support 1.5 source level. But You can try to download NetBeans IDE (from http://www.netbeans.org) and there with Visual Web project You will find the same functionality as for Creator. And 1.5 source level is supported by NetBeans.
    Thanks,
    Roman.

  • How to count the no of digits entered in the NumericField & print the same

    Hi!
    How to count the no of digits entered in the Numberic Field and print the content of Numberic Field.
    Thanks.

    Hi Venkat,
    To check the number of digits, just convert it to a string and use the length() method. to get the number of characters. However, I am not getting your second point of printing the number?
    Kindly explain in detail.
    Regards,
    Poojith MV

  • How to count the number of lines dynamically,

    In the below code am trying to read the lines which are selected using a check box, also am categorizing the contents depending on the follow up material.
    after displaying one category contents am displaying a line
    which also counts to a line in the internal table.
    My question is how to count the number of lines(ULINE) displayed dynamically.
    FORM GET_LINES .
      DATA: LV_LINES TYPE I,
            LV_TIMES TYPE I,
            LV_TABIX TYPE SY-TABIX.
      DESCRIBE TABLE IT_REC LINES LV_LINES.
      DO LV_LINES TIMES.
        LV_TIMES = SY-INDEX .
        READ LINE LV_TIMES FIELD VALUE IT_REC-CHECK INTO GV_CHECK.
        IF SY-SUBRC EQ 0 AND GV_CHECK IS NOT INITIAL.
          LV_TABIX =  LV_TIMES.
          READ TABLE IT_REC INDEX LV_TABIX INTO GWA_UPDATE.
          IF SY-SUBRC EQ 0.
            APPEND GWA_UPDATE TO GT_UPDATE.
          ENDIF.
        ENDIF.
      ENDDO.
    ENDFORM.                    " GET_LINES

    In the below code am trying to read the lines which are selected using a check box, also am categorizing the contents depending on the follow up material.
    after displaying one category contents am displaying a line
    which also counts to a line in the internal table.
    My question is how to count the number of lines(ULINE) displayed dynamically.
    FORM GET_LINES .
      DATA: LV_LINES TYPE I,
            LV_TIMES TYPE I,
            LV_TABIX TYPE SY-TABIX.
      DESCRIBE TABLE IT_REC LINES LV_LINES.
      DO LV_LINES TIMES.
        LV_TIMES = SY-INDEX .
        READ LINE LV_TIMES FIELD VALUE IT_REC-CHECK INTO GV_CHECK.
        IF SY-SUBRC EQ 0 AND GV_CHECK IS NOT INITIAL.
          LV_TABIX =  LV_TIMES.
          READ TABLE IT_REC INDEX LV_TABIX INTO GWA_UPDATE.
          IF SY-SUBRC EQ 0.
            APPEND GWA_UPDATE TO GT_UPDATE.
          ENDIF.
        ENDIF.
      ENDDO.
    ENDFORM.                    " GET_LINES
    The display function is:
    FORM DISPLAY_DATA .
      ULINE.
      WRITE :  /1 SY-VLINE, 'check',
                10 SY-VLINE, 'Plant',
               20 SY-VLINE, 'Material number',
               50 SY-VLINE, 'Follow up material',
               70 SY-VLINE, 'Safety stock',
              100 SY-VLINE, 'Partc'.
      ULINE.
      LOOP AT IT_MARC.
        MOVE: IT_MARC-WERKS TO IT_REC-WERKS,
              IT_MARC-MATNR TO IT_REC-MATNR,
              IT_MARC-NFMAT TO IT_REC-NFMAT,
              IT_MARC-EISBE TO IT_REC-EISBE,
              IT_MARC-PARTC TO IT_REC-PARTC .
        APPEND IT_REC.
        CLEAR IT_MARC.
      ENDLOOP.
      DATA: GV_TABIX TYPE SY-TABIX.
      LOOP AT IT_REC.
        GV_TABIX = SY-TABIX.
        READ TABLE GT_TOTAL WITH KEY WERKS = IT_REC-WERKS
                                     NFMAT = IT_REC-NFMAT.
        IF SY-SUBRC EQ 0.
          IT_REC-PARTC = GT_TOTAL-PARTC.
          MODIFY IT_REC INDEX GV_TABIX TRANSPORTING PARTC.
        ENDIF.
      ENDLOOP.
      LOOP AT IT_REC.
        WRITE : /1 SY-VLINE, IT_REC-CHECK AS CHECKBOX,
                10 SY-VLINE, IT_REC-WERKS,
                20 SY-VLINE, IT_REC-MATNR,
                50 SY-VLINE, IT_REC-NFMAT,
                70 SY-VLINE, IT_REC-EISBE,
               100 SY-VLINE, IT_REC-PARTC.
        AT END OF NFMAT.
          ULINE.
        ENDAT.
      ENDLOOP.
      ULINE.
    ENDFORM.                    " DISPLAY_DATA
    Solved

  • How to do the Record Level commit in DB Adapter

    Hi,
    I am using Oracle JDeveloper 11.1.1.6.0 and SOA server 11.1.1.6
    Problem Description_
    I am fetching multiple records using File Adapter in BPEL process, After Fetching I am writing those records in Database using Database Adpter.
    If any error records comes the database adpater rollback the complete transaction and none of the records is inserted into the Database.
    **Can anyone please tell me how to do the record level commit in Database Adapter so that All the success records can be inserted into the database except the Failure record*.*
    I dont want to call the Database adpater in loop multiple times to insert each record as it hampers the performance.
    Thanks in Advance
    Sunil

    I believe you are polling a file and inside the BPEL, inserting the records into the database using the database adapter.
    so according to your requirement you can do any one of the following things...
    1. Instead of using the database adapter for inserting the record, you can call a Stored Procedure which it takes the record fields as input and it inserts the record into the table and does a commit at the end. when you follow this approach, make sure your data source is defined as Non-XA, otherwise you will face some errors.
    2. If you are using the database adapter insert operation only, inside the BPEL, for the partnerlink of the database adapter, go to the properties and for the property "idempotent", give a value of false.
    by doing this, what happens means, after calling the database adapter from BPEL through the invoke activity, the transaction is committed and from the next activity i mean after the invoke, a new transaction will be started but it will use the same thread though
    3. If you are using the database adapter insert operation only, inside the BPEL, for the partnerlink of the database adapter, go to the properties and for the property "NonBlockingInvoke", give a value of true.
    by doing this, what happens means, the database adapter insert operation will happen in a separate transaction and it will be committed, inside the BPEL after the invoke activity, a new thread and transaction will be started
    4. Also, if you are using the database adapter insert operation, don't follow the steps as mentioned in either 2 or 3, you can simply put a dehydrate activity after the invoke activity.
    According to your requirement, all the four approaches works. But my personal feeling, don't go for 4, instead 1 is better, 2 or 3 is also good.
    Hope this helps,
    N

  • How do change the sound level input at the premiere cs6

    Hello:
             I would like to know how to change the sound level input al the premiere cs6?.
    Sincerely, Gabriel Conde

    The input sound levels will be determined by the media files you use.  The output volume can be adjusted in several ways.
    https://helpx.adobe.com/x-productkb/global/offline-help.html

  • How to calculate the RMS level of a signal with its spectral representation

    hi!
    how to calculate the RMS level of a signal with its spectral representation
    thanks

    1. Find the length, N, of the spectral signal.
    2. Convolve the magnitude of the signal with itself.
    3. Take the Nth element of the resulting signal
    4. Take the square root.
    5. This should be the RMS value of your signal.
    Randall Pursley
    Attachments:
    RMS.bmp ‏616 KB

  • How to count the number of wins?

    I have a tic tac toe simulator that simulates a game of tic tac toe (obviously). I press the 'play' button, and 1 random X and O is placed in 9 of the labels. Then the application says if X or O wins, or if the game was a tie/no winner.  So,
    what I want to do is when I click the 'exit' button, I want a message box telling the user how many times X won, O won, and how many ties there were.  I am not too sure how to count the number of wins.
    -Thanks

    Thanks for the reply.  I could be wrong, but I do not think that is exactly what I am looking for.  Here is the code that I have that determines the winner:
    switch (checkWinner())
    case 'T':
    winnerLabel.Text = "It was a tie!";
    break;
    case 'O':
    winnerLabel.Text = "O Wins!";
    break;
    case 'X':
    winnerLabel.Text = "X Wins!";
    break;
    private char checkWinner()
    char WinnerChar = ' ';
    int winning_line = 0;
    if (GameBoardCellChar[0].Equals(GameBoardCellChar[1]) && GameBoardCellChar[0].Equals(GameBoardCellChar[2]))
    WinnerChar = GameBoardCellChar[0];
    winning_line++;
    if (GameBoardCellChar[3].Equals(GameBoardCellChar[4]) && GameBoardCellChar[3].Equals(GameBoardCellChar[5]))
    WinnerChar = GameBoardCellChar[3];
    winning_line++;
    if (GameBoardCellChar[6].Equals(GameBoardCellChar[7]) && GameBoardCellChar[6].Equals(GameBoardCellChar[8]))
    WinnerChar = GameBoardCellChar[6];
    winning_line++;
    if (GameBoardCellChar[0].Equals(GameBoardCellChar[3]) && GameBoardCellChar[0].Equals(GameBoardCellChar[6]))
    WinnerChar = GameBoardCellChar[0];
    winning_line++;
    if (GameBoardCellChar[1].Equals(GameBoardCellChar[4]) && GameBoardCellChar[1].Equals(GameBoardCellChar[7]))
    WinnerChar = GameBoardCellChar[1];
    winning_line++;
    if (GameBoardCellChar[2].Equals(GameBoardCellChar[5]) && GameBoardCellChar[2].Equals(GameBoardCellChar[8]))
    WinnerChar = GameBoardCellChar[2];
    winning_line++;
    if (GameBoardCellChar[0].Equals(GameBoardCellChar[4]) && GameBoardCellChar[0].Equals(GameBoardCellChar[8]))
    WinnerChar = GameBoardCellChar[0];
    winning_line++;
    if (GameBoardCellChar[2].Equals(GameBoardCellChar[4]) && GameBoardCellChar[2].Equals(GameBoardCellChar[6]))
    WinnerChar = GameBoardCellChar[2];
    winning_line++;
    if (winning_line == 0 || winning_line > 1)
    WinnerChar = 'T';
    return WinnerChar;
    Do I have to include something extra in here to get the count or no?
    The code I posted is the coding in my play button.

  • How to count the number of text boxes that are data entered

    How to count the number of text boxes that are data entered in visual basic form.

    Here is an Iterator that expands on my previous response:
    ''' <summary>
    ''' Iterator for form controls
    ''' </summary>
    ''' <param name="onlyControlsOfType">specify type if a certain type of controls needed</param>
    ''' <param name="onlyTopLevel">if true don't search containers within the form</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Iterator Function AllControls(Optional onlyControlsOfType As Type = Nothing, _
    Optional onlyTopLevel As Boolean = False) As IEnumerable(Of Control)
    Dim ctrl As Control = Me.GetNextControl(Me, True)
    Do Until ctrl Is Nothing
    If onlyControlsOfType Is Nothing OrElse ctrl.GetType = onlyControlsOfType Then
    If TypeOf ctrl.Parent Is Form OrElse Not onlyTopLevel Then
    Yield ctrl
    End If
    End If
    ctrl = Me.GetNextControl(ctrl, True)
    Loop
    End Function
    Some sample uses:
    For Each
    For Each c As Control In AllControls()
    Debug.WriteLine(c.Name)
    Next
    List of all controls, including controls in containers i.e. Groupbox
    Dim l As List(Of Control) = AllControls().ToList
    List of all Textbox controls, including Textboxes in containers i.e. Groupbox
    l = AllControls(GetType(TextBox)).ToList
    List of all Textbox controls, don't include Textboxes in containers i.e. Groupbox
    l = AllControls(GetType(TextBox), True).ToList
    'Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it.'  JohnWein
    Multics
    My Serial Port Answer

  • How to count the number of AAA clients

    Hi,
    As we know, ACS5.2 is required with a base license-- supporting 500 network devices.
    Sometimes there are lots of AAA clients or network devices that are authenticating simultanious. So my question is, how to count the network devices allowed to auth on ACS5.2? Does that only include network devices, or including both any network devices or AAA clients?
    Rgds,
    Laowu5017

    Hi,
    ACS 5.x counts the number of AAA clients that are configured on the ACS.
    Please note that AAA clients and networks devices is the same and they comply switches, routers, WLCs, or whatever other device configured under
    Network Resources >
    ... >
    Network Devices and AAA Clients
    AAA Clients are NOT the AAA suplicants.
    The end user clients PCs are the AAA suplicants, and for this there is no limit number.
    HTH,
    Tiago
    If  this helps you and/or answers your question please mark the question as  "answered" and/or rate it, so other users can easily find it.

  • How to count the no of record in grid.

    Hi Experts,
    I have one database block & this is bolck has contain 4 non database item is there. In database block has contain the id and description is non database block item. While i m querying the data description is shown depends up on ID. It is in grid. How to count the no of record in grid. My code is
    LV_CUR_ITM :=:SYSTEM.CURSOR_RECORD;
    FOR I IN 1.. LV_CUR_ITM LOOP
    LAST_RECORD;
    SELECT NSN_NO INTO :ORD_DIS_NSN_ITEM_DET.NSN_NO
    FROM NSN_MST WHERE NSN_ID= :ORD_DIS_NSN_ITEM_DET.NSN_ID;
    SELECT FOB_PRICE INTO :ORD_DIS_NSN_ITEM_DET.FOB_PRICE
    FROM PRODUCT_SUPPLIER WHERE PRD_ID_NUMBER= :ORD_DIS_NSN_ITEM_DET.PRD_ID_NUMBER
    AND BAS_ORG_ID_NUMBER=:ORD_DIS_NSN_ITEM_DET.ORG_ID_NUMBER;
    SELECT DESCRIPTION INTO :ORD_DIS_NSN_ITEM_DET.PRD_DESC
    FROM PRODUCT WHERE ID_NUMBER= :ORD_DIS_NSN_ITEM_DET.PRD_ID_NUMBER;
    SELECT FULL_NAME INTO :ORD_DIS_NSN_ITEM_DET.SUPP_NAME
    FROM ORGANISATION WHERE ID_NUMBER=:ORD_DIS_NSN_ITEM_DET.ORG_ID_NUMBER;
    NEXT_record;
    END LOOP;
    Thx in advance.

    Hai,
    Add a Non database item to that block, and set the Calculation Mode as Summary, and Summary Function to Count.
    Then u will get the total no of records from this text. ( You can hide this, so that the use won't see it. )
    OR
    go to the Last Record, then
    LV_CUR_ITM :=:SYSTEM.CURSOR_RECORD; This will also work.
    Regards,
    Manu.
    If this answer is helpful or correct, please mark it. Thanks.

  • How to count the number or rows in file

    Hi Experts,
    I am file as source and Oracle as target. My file containing the some data which is going to load to the target.
    My requirement is that I want to count the number of rows which my file contains. Please help me how to count the total number of rows in file.
    Thx,
    Sahadeva.

    Hi,
    You won't give a name DEST_USER_NAME:ODI will get these information.
    it is important  Command on source and Command on Source side .
    -Pls write jython code on Command on Source side
    -And Command On Target side Choose technology as Oracle and set logical schema to HR_logical
    Sorry my mistake.İt is related jython syntax.Here is code:
    import java.lang as lang
    import java.sql as sql
    import java.lang.String
    import os
    lang.Class.forName("<%=snpRef.getInfo("DEST_JAVA_DRIVER")%>")
    cons=sql.DriverManager.getConnection("<%=snpRef.getInfo("DEST_JAVA_URL")%>", "<%=snpRef.getInfo("DEST_USER_NAME")%>", "<%=snpRef.getInfo("DEST_PASS")%>")
    dblinks= cons.createStatement()
    file1=open('EMP.txt','r')
    count=0
    line=file1.readline()
    while line !='':
         count+=1
         line=file1.readline()
    file1.close()
    sqlQuery = "insert into HR.ETL_FILE_LOG (FILE_COUNT) values (count)"
    rqQuery= dblinks.execute(sqlDBLink)
    cons.close()
    Regards

  • How to limit the Tree's level

    Hi all,
    I have a tree with 10 levels, But I want it just display from level 1 to level 4, The node bigger than level4 will not be displayed on the tree. How can I implement this issue? Thanks a lot!
    Regards,
    Peter

    JNI is java native interface. It let us allow platform dependent code in c / c++ and we can use it them in java.
    JNI should be used only when you need to do some thing faster in native machine language. You problem is too trivial to use JNI. So better stick to what sun people have done..
    for more info : http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jni.html

  • HOw to Get the top level of Hierarchy and count on that basis

    hi
    i have following tables
    desc hr_organizations_units_V
    organization_id PRIMARY KEY
    name
    ORGANIZATION_type
    per_org_structure_elements
    organization_id_parent FK TO hr_organizations_units_V(ORGANIZATION_ID)
    organization_id_child FK TO hr_organizations_units_V(ORGANIZATION_ID)
    I HAVE THIS QUERY TO GET PARENT CHILD
    SELECT ORGANIZATION_ID_PARENT PARENT,ORGANIZATION_ID_CHILD CHILD,ORGANIZATION_TYPE FROM PER_ORG_STRUCTURE_ELEMENTS OSE,HR_ALL_ORGANIZATION_UNITS AOU WHERE AOU.ORGANIZATION_ID = OSE.ORGANIZATION_ID_CHILD CONNECT BY PRIOR ORGANIZATION_ID_CHILD = ORGANIZATION_ID_PARENT
    START WITH ORGANIZATION_ID_PARENT = 82 -- THE GRAND PARENT
    ORDER BY ORGANIZATION_ID_PARENT
    PARENT CHILD ORGANIZATION_TYPE
    82 83 COMPANY
    82 143 COMPANY
    83 84 DIVISION
    83 134 DEPARTMENT
    83 135 DEPARTMENT
    DESC per_all_assignments_f
    ASSIGNMENT_NUMBER
    ORGANIZATION_ID FORIGN KEY TO HR_ALL_ORGANIZATION_UNITS
    THE ASSIGNMENTS ARE ASSIGNED ON DEPARTMENT LEVEL.
    MY REQUIREMENT IS THAT I WANT TO GET THE
    1)TOTAL NO OF ASSIGNMENTS ON THE DIVISION LEVEL
    2)TOTAL NO OF ASSIGNMENTS ON THE COMPANY LEVEL
    3)REPORTS LIKE PAY SLIP ETC I WANT TO GET THE ABOVE TWO LEVELS OF ORGANIZATION FOR EACH EMPLOYEE I.E DIVISION AND COMPANY OF
    OF THE EMPLOYEE'S DEPARTMENT.
    I WILL REALLY APPRECIATE ANY HELPING HAND.
    REGARDS

    Here are a few ways to get what I think you are asking for now. If this is not what you want, then please provide a complete example of what you want, including sample data, and the complete query result, including numbers, based on that data, that you want, as I have done below.
    scott@ORA92> -- test data:
    scott@ORA92> SELECT * FROM hr_all_organization_units
      2  /
    ORGANIZATION_ID NAME                                ORGANIZATIO
                 82 GRANDPARENT                         GRANDPARENT
                 83 COMPANY 83                          COMPANY
                 84 DIVISION 84                         DIVISION
                134 DEPARTMENT 134                      DEPARTMENT
                135 DEPARTMENT 135                      DEPARTMENT
                143 COMPANY 143                         COMPANY
    6 rows selected.
    scott@ORA92> SELECT * FROM per_org_structure_elements
      2  /
    ORGANIZATION_ID_PARENT ORGANIZATION_ID_CHILD
                        82                    83
                        82                   143
                        83                    84
                        84                   134
                        84                   135
    scott@ORA92> SELECT * FROM per_all_assignments_f
      2  /
    ASSIGNMENT_NUMBER ORGANIZATION_ID
                    1              83
                    2              84
                    3             134
                    4             135
                    5             143
                    6              84
    6 rows selected.
    scott@ORA92> -- method 1:
    scott@ORA92> COLUMN  name FORMAT A35
    scott@ORA92> SELECT  RPAD ('.', 5 * (LEVEL - 1), '.') || aou.name AS name,
      2           (SELECT SUM (the_count)
      3            FROM   (SELECT organization_id_parent,
      4                     organization_id_child,
      5                     COUNT (*) AS the_count
      6                 FROM   per_org_structure_elements,
      7                     per_all_assignments_f
      8                 WHERE  per_org_structure_elements.organization_id_child =
      9                     per_all_assignments_f.organization_id
    10                 GROUP  BY organization_id_parent,
    11                     organization_id_child) t
    12            START  WITH t.organization_id_child =
    13                  ose.organization_id_child
    14            CONNECT BY PRIOR t.organization_id_child =
    15                       t.organization_id_parent) AS assignments_count
    16  FROM   PER_ORG_STRUCTURE_ELEMENTS OSE,
    17           HR_ALL_ORGANIZATION_UNITS  AOU
    18  WHERE  AOU.ORGANIZATION_ID = OSE.ORGANIZATION_ID_CHILD
    19  START  WITH aou.name = '&company_name'
    20  CONNECT BY PRIOR ose.ORGANIZATION_ID_CHILD = ose.ORGANIZATION_ID_PARENT
    21  /
    Enter value for company_name: COMPANY 83
    old  19: START  WITH aou.name = '&company_name'
    new  19: START  WITH aou.name = 'COMPANY 83'
    NAME                                ASSIGNMENTS_COUNT
    COMPANY 83                                          5
    .....DIVISION 84                                    4
    ..........DEPARTMENT 134                            1
    ..........DEPARTMENT 135                            1
    scott@ORA92> -- method 2:
    scott@ORA92> COLUMN  name FORMAT A35
    scott@ORA92> WITH sub_query AS
      2  (SELECT ose.organization_id_parent, ose.organization_id_child,
      3            aou.name, COUNT (*) AS assignments
      4   FROM   per_org_structure_elements ose,
      5            hr_all_organization_units     aou,
      6            per_all_assignments_f     aaf
      7   WHERE  ose.organization_id_child = aou.organization_id
      8   AND    ose.organization_id_child = aaf.organization_id
      9   AND    aou.organization_id = aaf.organization_id
    10   GROUP  BY ose.organization_id_parent, ose.organization_id_child, aou.name)
    11  SELECT RPAD ('.', 5 * (LEVEL - 1), '.') || name AS name,
    12           (select SUM (assignments)
    13            from   sub_query
    14            start  with organization_id_child = t.organization_id_child
    15            connect by prior organization_id_child = organization_id_parent)
    16           AS assignments_count
    17  FROM   sub_query t
    18  START  WITH name = '&company_name'
    19  CONNECT BY PRIOR ORGANIZATION_ID_CHILD = ORGANIZATION_ID_PARENT
    20  /
    Enter value for company_name: COMPANY 83
    old  18: START  WITH name = '&company_name'
    new  18: START  WITH name = 'COMPANY 83'
    NAME                                ASSIGNMENTS_COUNT
    COMPANY 83                                          5
    .....DIVISION 84                                    4
    ..........DEPARTMENT 134                            1
    ..........DEPARTMENT 135                            1
    scott@ORA92> -- method 3:
    scott@ORA92> COLUMN  name FORMAT A35
    scott@ORA92> CREATE OR REPLACE VIEW sub_query AS
      2  SELECT ose.organization_id_parent, ose.organization_id_child,
      3           aou.name, COUNT (*) AS assignments
      4  FROM   per_org_structure_elements ose,
      5           hr_all_organization_units  aou,
      6           per_all_assignments_f      aaf
      7  WHERE  ose.organization_id_child = aou.organization_id
      8  AND    ose.organization_id_child = aaf.organization_id
      9  AND    aou.organization_id = aaf.organization_id
    10  GROUP  BY ose.organization_id_parent, ose.organization_id_child, aou.name
    11  /
    View created.
    scott@ORA92> SELECT RPAD ('.', 5 * (LEVEL - 1), '.') || name AS name,
      2           (select SUM (assignments)
      3            from   sub_query
      4            start  with organization_id_child = t.organization_id_child
      5            connect by prior organization_id_child = organization_id_parent)
      6           AS assignments_count
      7  FROM   sub_query t
      8  START  WITH name = '&company_name'
      9  CONNECT BY PRIOR ORGANIZATION_ID_CHILD = ORGANIZATION_ID_PARENT
    10  /
    Enter value for company_name: COMPANY 83
    old   8: START  WITH name = '&company_name'
    new   8: START  WITH name = 'COMPANY 83'
    NAME                                ASSIGNMENTS_COUNT
    COMPANY 83                                          5
    .....DIVISION 84                                    4
    ..........DEPARTMENT 134                            1
    ..........DEPARTMENT 135                            1

Maybe you are looking for

  • Can you transfer music from your iPod to your iTunes Library?

    I am an avid MTB and I have an iPod Nano 4G for when I'm biking around. But when I go on the road I have my 30G Video. The other day I got some songs from a friends computer and I am wondering if there is a way to transfer my music from my Nano into

  • Radio Buttons problem

    Hi i ahve developed a GUI with 2 toggle buttons options[0] and options[1],I have also created an "OK" Button.the programming is working fine ,but i now want to implement the action performed method.The user must select which option he/she wants and t

  • Massive RSS and Network Problems

    When I try and refresh my RSS feeds I get an error message that says *+There was an error updating the RSS feeds.+* +Mail cannot start a session with the system-wide RSS service. No RSS feeds will be refreshed.+ Also when I click the RSS icon in safa

  • I plan to buy the new iPod Touch 8 gig.  How many songs can be stored on it

    I plan to buy the new iPod Touch 8 gig.  How many songs can be stored on it

  • Why We Use Databases?

    Please give me some detail. or some link, on this question.