Find highest  order and last node in a tree..

the problem is:-
suposse A is parent node and order 1
A's child is B and order 2
B's child is C and order 3
B's child is D and order 4
D child is E order 5
E child is F order 6
A's child is G and order 7
how can i find the highest order is 7 and last node is F order 6 of above thee?
order is from which tree is sorted assecnding.
Edited by: user1157479 on Aug 24, 2009 10:57 PM

with t as (
select '' par,'A' chi from dual union all
select 'A' par,'B' chi from dual union all
select 'B' par,'C' chi from dual union all
select 'C' par,'D' chi from dual union all
select 'D' par,'E' chi from dual union all
select 'E' par,'F' chi from dual union all
select 'A' par,'G' chi from dual )
select maxlvl,chi,maxorder from (select p.*,max(lvl) over () maxlvl,max(rnum) over () maxorder from (select t.*,level lvl,rownum rnum from t connect by prior chi=par start with chi='A') p)  where rnum=maxlvlRavi Kumar
Edited by: ravikumar.sv on Aug 25, 2009 11:45 AM

Similar Messages

  • Programmatic, using bean add Parent and child nodes in af:tree dynamically

    Hi All,
    i have to add parent and child nodes dynamically in tree .
    Example :
    i have created a tree like below.On click of button i will get value A ,from pl/sql function i will A1 and A 2 values.which i have to show in pop as tree.
    A
    |-----A1
    |-----A2
    If user clicks on A2.I have to catch A2 value and pass to pl/sql function which gives A2.01 and A2.02 values.
    A
    |-----A1
    |-----A2
    |------A2.01
    |------A2.02.
    A, A1 ,A2,A2.01 ...........values comes from pl/sql funchtion .
    thanks in advance ......... any suggestion will greatly helps

    no use ......................

  • Find the first and last day of week giving a certain date

    Hi,
    i have an application in wich the user puts a date, say today 2010-08-10 and i have to calculate first and last day of that week, in this case 2010-08-09 and 2010-08-15. How can i do this?
    Many thanks in advance,
    Nuno Almeida

    nfalmeida wrote:
    i have an application in wich the user puts a date, say today 2010-08-10 and i have to calculate first and last day of that week, in this case 2010-08-09 and 2010-08-15. How can i do this?First step is being sure that you know what a 'week' is.
    For example does it really start on monday? And will it always start on monday?
    And what day does the 'week' end on for 2010-12-29? In some businesses it will end on 2010-12-31 (friday)

  • How to find open orders and open quantity

    Hi abap gurus,
    i want to find the open orders with the quantity  means those orders for which we don't have goods issues(and partial deliverys is also possible). i get this scenario but i don't know how to start.
      i think i should go to VBUP table and get all the orders
      which have overall status GBSTA = 'A' OR 'B'.
      So from this i will get all the open orders but i need to find open quantity also .
      please tell me how can i find out and  which table do i need to use.

    You need to check between delivery line item table as well sales order line item table.
    Sales order Line item table : VBAP
    Delivery line item table : LIPS
    if order qty and delivery qty are same then there is no open qty if not then there is open qty.
    Thanks
    Seshu

  • Finding the "last node" in a hierarchical query?

    I'm presented with an issue - find all parent records for which the "last node" in a hierarchy is not set to some value.
    Table structure:
    child_id number
    parent_id number
    type_id number
    So, I need to find all parents whose eventual last "children" (could be several levels deep, it varies) do not have a type_id of 29.
    I can find the hierarchy easily using connect by prior but I'm stuck on that "last node" bit. Any help out there?

    user9937402 wrote:
    I'm finding that the CONNECT_BY_ISLEAF is showing all leaves set to 0, even if they themselves are parents (i.e. not the last node in the tree).
    Post your code.
    I'm not following the 2nd example. Where are you getting those values? This is a really large table, so if that is actual data ... that won't work.Since you did not post data sample, SBH cooked up one on-the-fly using subquery factoring clause - WITH. Below is example on existing table, so I don't need to use WITH:
    SQL> select  lpad(' ',level*2) || ename ename,
      2          connect_by_isleaf
      3    from  emp
      4    start with mgr is null
      5    connect by mgr = prior empno
      6  /
    ENAME                                                                CONNECT_BY_ISLEAF
      KING                                                                               0
        JONES                                                                            0
          SCOTT                                                                          0
            ADAMS                                                                        1
          FORD                                                                           0
            SMITH                                                                        1
        BLAKE                                                                            0
          ALLEN                                                                          1
    ENAME                                                                CONNECT_BY_ISLEAF
          WARD                                                                           1
          MARTIN                                                                         1
          TURNER                                                                         1
          JAMES                                                                          1
        CLARK                                                                            0
          MILLER                                                                         1
    14 rows selected.
    SQL> As you can see CONNECT_BY_ISLEAF works as expected.
    SY.

  • How to find first and last date of a fiscal week using SQL

    Hello,
    I want information about FISCAL Week, means a Week based on ISO standard. I know format strings ‘IW’ or ‘IYYY’ gives fiscal week and fiscal year respectively from a given date. But I want to find the first and last date of a fiscal week. Say suppose I have a fiscal week is 2, and fiscal year is 2008, how to find the start and end date of the given fiscal week.
    Any kind of help would be greatly appreciable.
    Thanks,
    Prince

    davide gislon wrote:
    The following query evaluate the begin of a fisical week, where &year and &week are respectively the year and week you want to calculate.
    To evaluate the end of the week you have to add 6.
    Note that my database is set to have monday as day number 1 of the week, and sunday as day number 7; if your database settings are different you should modify the query accordingly.
    SELECT CASE TO_CHAR(TO_DATE('&year','YYYY'),'D')
    WHEN '1' THEN TO_DATE('&year','YYYY')+((&week-1)*7)
    WHEN '2' THEN TO_DATE('&year','YYYY')+((&week-1)*7-1)
    WHEN '3' THEN TO_DATE('&year','YYYY')+((&week-1)*7-2)
    WHEN '4' THEN TO_DATE('&year','YYYY')+((&week-1)*7-3)
    WHEN '5' THEN TO_DATE('&year','YYYY')+((&week-1)*7+3)
    WHEN '6' THEN TO_DATE('&year','YYYY')+((&week-1)*7+2)
    WHEN '7' THEN TO_DATE('&year','YYYY')+((&week-1)*7+1)
    END BEGIN_FISICAL_WEEK
    FROM DUAL
    Hope this is helpful.
    Cheers,
    Davide
    Edited by: davide gislon on 08-Jan-2009 07:19Your query does nothing you say it does. TO_DATE('&year','YYYY') returns first day of the current month for year &year. And the only reason it returns January 1, &year is that we are currently in January:
    SQL> select TO_DATE('&year','YYYY') from dual
      2  /
    Enter value for year: 2005
    old   1: select TO_DATE('&year','YYYY') from dual
    new   1: select TO_DATE('2005','YYYY') from dual
    TO_DATE('
    01-JAN-05
    SQL> As soon as we roll into February:
    SQL> alter system set fixed_date = '2009-2-1' scope=memory
      2  /
    System altered.
    SQL> select sysdate from dual
      2  /
    SYSDATE
    01-FEB-09
    SQL> select TO_DATE('&year','YYYY') from dual
      2  /
    Enter value for year: 2005
    old   1: select TO_DATE('&year','YYYY') from dual
    new   1: select TO_DATE('2005','YYYY') from dual
    TO_DATE('
    01-FEB-05
    SQL> alter system set fixed_date = NONE scope=both
      2  /
    System altered.
    SQL> select sysdate from dual
      2  /
    SYSDATE
    08-JAN-09
    SQL> But even if TO_DATE('&year','YYYY') would always return January 1, &year, or you would fix it to TO_DATE('0101&year','MMDDYYYY') it still would be wrong. ISO week rules are
    If January 1 falls on a Friday, Saturday, or Sunday, then the week including January 1 is the last week of the previous year, because most of the days in the week belong to the previous year.
    If January 1 falls on a Monday, Tuesday, Wednesday, or Thursday, then the week is the first week of the new year, because most of the days in the week belong to the new year.Therefore, next year:
    SQL> DEFINE YEAR=2010
    SQL> DEFINE WEEK=1
    SQL> ALTER SESSION SET NLS_TERRITORY=GERMANY -- enforce Monday as first day of the week
      2  /
    Session altered.
    SQL> SET VERIFY OFF
    SQL> SELECT CASE TO_CHAR(TO_DATE('0101&&year','MMDDYYYY'),'D')
      2  WHEN '1' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7)
      3  WHEN '2' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7-1)
      4  WHEN '3' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7-2)
      5  WHEN '4' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7-3)
      6  WHEN '5' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7+3)
      7  WHEN '6' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7+2)
      8  WHEN '7' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7+1)
      9  END BEGIN_FISICAL_WEEK
    10  FROM DUAL
    11  /
    BEGIN_FI
    04.01.10
    SQL> SELECT TRUNC(TO_DATE('0101&&year','MMDDYYYY'),'IW') FROM DUAL
      2  /
    TRUNC(TO
    28.12.09
    SQL> 2 user10772980:
    Use:
    SELECT  TRUNC(TO_DATE('0101&&year','MMDDYYYY'),'IW') + (&&week-1)*7 FISCAL_YEAR_&&YEAR._WEEK_&&WEEK
      FROM  DUAL
    FISCAL_YEAR_2010_WEEK_1
    28.12.09
    SQL> SY.

  • How to disable "Expand All" and "Collapse All" when no node in a tree

    I have a <af:tree> inside <af:panelCollection>.
    All items under viewMenu like "Expand", "Expand All Below", "Collapse All Below", "Expand All" , "Collapse All", "Scroll to First" and "Scroll to Last" are implemented by default.
    When there is no node in a tree, "Expand", "Expand All Below", and "Collapse All Below" are grey out.
    However, "Expand All" , "Collapse All", "Scroll to First" and "Scroll to Last" are still enabled to be clicked.
    Is there any way we can diable them when no node?

    When I highlight last node in the tree and all nodes are collapsed, I see "Expand All Below" enabled but "Collapse All Below" disabled. Which is expected. Expand All Below will expand all the child nodes under a node.
    QA filed a bug said that "Expand All Below" should be disabled since no node below it. However, I don't find any place to control them. Can you confirm this? Or you know some way to do this?It it not a bug then. You don't have to control it and framework takes care of enabling and disabling it accordingly.
    If you need to expand all the nodes programatically, check this out.
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/78-man-expanding-trees-treetables-354775.pdf
    -Arun

  • Credit limit and last paid amount by the customer

    Hello,
    I have one requirement in Account Receivable cube (0FI_AR_4). I need to find CREDIT LIMIT and LAST PAID DATE
    So I had done the enhancement for 0FI_AR_4  data source and populated the required values. I had checked in RSA3 for the accuracy of data and everything looks fine.. (in RSA3 every line item for particular customers will be populated with the Credit limit and last paid date. )
    Then I created 2 Info Object KEY FIGURES in BW and added it to the 0FI_AR_4 Cube.. .. the info object should display only the latest credit limit maintained and the last payment date for the particular customer. So i have some doubt about the property setting of the INFO OBJECT. Could any one please assist me, what setting is required to fetch only latest credit limit and last payment date.
    Thanks
    Sachin

    Dear Sachin
    The credit limit and last payment date is available as part of the standard source FI_AR_9.
    Now if you have appended the same in the FI_AR_4 , you can maintain both the fields as keyfigure. For credit limit bring in the currency also in the append
    Credit Limit - Keyfigure as Amount with Unit 0CURRENCY
    Date of last payment -  Keyfigure as Date
    Regards
    Gajesh

  • Default Internal order and cost center

    Hi Experts,
    i am uploading one file into sap and here i am giving GL accounts cost centers and WBS elements.
    once i have done with upload.when i am checking in BSEG its showing one internal order and one default cost center with internal order.
    i can not understand how its finding internal order and default cost cente(which diffetrent from those cost centers i have mentioned in excel).
    please help me to find.
    thanks,
    Vani

    HI,
    Thanks for your reply.
    i have checked OKB9 and KA03 but there is no default assignment.
    checked also OBBH and OKC9 but no subtitution and i can't post manually now.
    is there any option.
    Waiting for your reply.
    Thanks,
    Vani

  • How to drag and drop nodes in Tree?

    Hi,
    I want to drag and drop nodes in the tree. For example a tree represents the hierarchy of employees reporting in an organization by using tree.I want to change the reporting an employee visible in the tree by simple drag and drop operation in place of going to another form for updating each employee record indiviually.
    Regards
    Piyush

    Ron,
    I looked into implementing drag / drop in one of the apex trees I created today and ran across this thread. Thank you Ron for the links, it helped a lot.
    I added the code below to my page's "Execute when Page Loads" (tree region id is "tree_reg") and the tree is now drag/drop enabled.
    It did break the [+] icon from collapsing the tree though ... but the apex.widget.tree buttons still work
    var regTree = apex.jQuery("#tree_reg").find("div.tree");
    regTree.tree({ 
    callback : {
    onmove: function(NODE, TREE_OBJ, REF_NODE, TYPE)
    {alert(NODE.id+"   "+TREE_OBJ.id+"   "+ REF_NODE);}
    });Next, I plan on creating a AJAX call using NODE.id, TREE_OBJ.id, and REF_NODE
    V/R
    Ricker

  • I could not find my order even when I received an email that my order was filled?

    It is so problematic!  I can't find my order and I can't download to install.

    Contact support directly by phone or web chat.
    Mylenium

  • I ordered Adobe XI pro last year and need to reinstall it.  I cannot find my serial number. I downloaded the software online.  Can you look up my order. I ordered it last year around this time.

    I ordered Adobe XI pro last year and need to reinstall it.  I cannot find my serial number. I downloaded the software online.  Can you look up my order. I ordered it last year around this time.@

    Once you get your S/N and download the software, back them up to a CD or backup HD. Not doing that is like purchasing a CD, installing software, and tossing the CD in the trash.

  • Finding first and last members of a group set

    Is there any example how to use 'first' and 'last' functions in an sql query ?
    I have tried to execute a query like this on the scott.emp table :
    select deptno,min(sal),max(sal),first(sal) from emp group by deptno;
    but I always get this message:
    ERROR at line 1:
    ORA-00904: "FIRST": invalid identifier
    btw I use Oracle RDBMS ver 9.1.0.3 for Solaris in my server.
    tx for your help
    sjarif

    Syarif,
    The FIRST and LAST functions, which became available with 9i, are used to find the first or last member of a ranked set. I'm not sure exactly what you are trying to do, but I can show you a query that should work (I don't have 9i handy at the moment). This query should give you the departments with the highest (first) and lowest (last) aggregate salaries:
    select deptno,
    min(deptno)
    keep (dense_rank first order by sum(sal) desc) highest_sal,
    min(deptno)
    keep (dense_rank last order by sum(sal) desc) lowest_sal
    from emp
    group by deptno
    Is there any example how to use 'first' and 'last' functions in an sql query ?
    I have tried to execute a query like this on the scott.emp table :
    select deptno,min(sal),max(sal),first(sal) from emp group by deptno;
    but I always get this message:
    ERROR at line 1:
    ORA-00904: "FIRST": invalid identifier
    btw I use Oracle RDBMS ver 9.1.0.3 for Solaris in my server.
    tx for your help
    sjarif

  • Is possible to change the order of name and last n...

    After to have installed: "Nokia PC Suite 6.84.10.3 ita", I have noticed that the names in the Contacts folder, come lists to you with the following order: "name for first and last name for second". I have tried to change this order, opening Nokia Contacts Editor, selecting Options > Order names > Last name for first, rebboting Nokia Phone Browser and Nokia Contacts Editor in order to render effective the modifications, but nothing
    to make. Why in the previous versions of PC Suite, it was possible to change this order (Name for first or Last name for first), and instead in the version "Nokia PC Suite 6.84.10.3" it is not possible? Someone of You have the same problem? How I could resolve it? Thanks in
    advance!!

    vCard file is in plain text. you can edit it using text editor - find field like:
    N:han;abrash
    the first name and last name is seperated by ';' there. and you can reorder it to:
    N:abrash:han
    done
    What's the law of the jungle?

  • HT1414 I backed up my iphone last weekend.  Today (one week later), I was downloading music and noticed the text messages I send to myself (about 1 1/2 years worth) are gone.  Now, I can't find the backup from last week to try to get them back.  help???

    I backed up my iphone last weekend.  Today (one week later), I was downloading music and noticed the text messages I send to myself (about 1 1/2 years worth) are gone.  Now, I can't find the backup from last week to try to get them back.  help???

    You cannot update iPhone 4 to IOS 8.1.2, the highest you can update is IOS 7.1.2.
    Unless you've iPhone 4S (looks similar to iPhone 4)

Maybe you are looking for

  • My phone is stuck on the apple and my home button doesn't work. How do i fix it?

    HELP,it's my phone and i need to be able to go on it.i have a problem with a family member.

  • External HP Pavilion 23xi monitor cuts off laptop audio

    I want to use my HP Pavilion 23xi monitor as an external monitor for my laptop (Sony Vaio, Windows 7).  The laptop only has an HDMI connection, so I used an HDMI cable to connect it.  The HP monitor works fine, but when it is connected, it cuts off a

  • Service Purchase Order

    Hi MM Gurus, Scenario is Service Purchase Order for Travelling Charges , Service maintained at service tab is travelling charges 12 nos for 38000/- each item cat D . In main text of PO item qty appears is 1 nos and amount is 456000/- ok. Service tax

  • Report to find Users that cannot Shop?

    Hi All, Is there a report/program in SRM 5.0 that can tell what users are not configured correctly that will not allow them to shop? Also does the same report run in SRM 4.0? Thanks, Nikhil Edited by: Nikhil Malvankar on Nov 24, 2008 6:49 PM Edited b

  • Word 2007 Corrupt Document Recovery

    Hi All, I might be a little off topic in this category but am hoping you can help or point me in the right direction, i have a corrupt .doc document, basically it was a doc i resumed working on which was launched off a usb hdd, midway through the doc