Get only last level in SQL Hierarchy Query

Hi,
How to get only the last level in Oracle SQL Hierarchy Query?
Thanks

Hi,
1007372 wrote:
Hi,
How to get only the last level in Oracle SQL Hierarchy Query?Depending on your requirements:
WHERE   CONNECT_BY_ISLEAF  = 1 
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
If you can show what you want to do using commonly available tables (such as scott.emp, which contains a hierarchy), then you don't need to post any sample data; just the results and the explanation.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0). This is always important, but especially so with CONNECT BY queries, because every version since Oracle 7 has had significant improvements in this area.
See the forum FAQ {message:id=9360002}

Similar Messages

  • Hierarchy authorization details show only last level

    Hi,
    I am facing on a hierarchy problem displayed on the Bex: The hierarchy has 9 levels, e.g. the organisation structure of the company from level 1 to level 9.
    I made from the transaction RSSM :
    Authorization from the hierarchy i entered for each level from 1 to 9 :
    Type of authorisation : 1 (subtree below node)
    Hierarchy level       : blank
    Validity period       : blank
    Node variable default value : blank
    I made from the transaction PFCG :
    Created a role for the user with the authorization :
    Sap Business information warehouse - reporting (RSR)
    value : 8055 (company code)
    Unique ID for authorization : level_3
    I need to authorize the user to execute a querry of his level (exemple level 3) and all the level below him (to the 9th level)
    When the query is generated,(the query is using a variable hierarchy ) I get the lowest level displayed and shows only 2 key figures and values.
    Any ideas ?
    You assistance will be appreciated.
    Thong VANNAXAY

    Hi,
    1007372 wrote:
    Hi,
    How to get only the last level in Oracle SQL Hierarchy Query?Depending on your requirements:
    WHERE   CONNECT_BY_ISLEAF  = 1 
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    If you can show what you want to do using commonly available tables (such as scott.emp, which contains a hierarchy), then you don't need to post any sample data; just the results and the explanation.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0). This is always important, but especially so with CONNECT BY queries, because every version since Oracle 7 has had significant improvements in this area.
    See the forum FAQ {message:id=9360002}

  • Query on 0TCT_MC01 to get the last used date of a query

    Dear All,
    I tried to create a query on 0TCT_MC01 to get the last used date of a query.
    Since we do not have readily available key figure for Last used date, could any one help me out to achieve this result?
    I am interested to find the old queries which are not being used anymore.
    Thanks in advance.

    You can get the info from the below tables
    if you are working with BW 3.5 you can look in table RSDDSTAT in BI 7.0 it is RSDDSTAT_OLAP.
    Make a selction on the infocube and the OLAP Statistic Object which is the query ID and execute. Then you should see how often the query was executed, by whom and which date/time.
    in field Statistics Object Name Query ID you type in the tech name of the query
    from the Counter for statistics event calls -- will give the count... no of times the query used least the count lesser the query is used.
    Regards
    KP
    Edited by: Konduru Prashanth. on Dec 22, 2011 2:44 PM

  • Display the technical name of the last level of the hierarchy

    Hello,
    I have a report with hierarchy. Each level of the hierarchy uses different infoObject. I want the report to display the technical name only for nodes from specific infoObject. For example if the infoObject uses 0cust_grp1 (for the first level), 0cust_grp2 (for the second level), 0cust_grp3 (for the third level) and 0customer (for the last level) and I want to show the technical name only for the 0customer infoObject. I know how to do it in WAD reports. Is there a way of doing it in the Query Designer?
    Please Advice,
    David

    David,
          Check the below possibilities.
    1. You can do that in a workbook.
    2. Create a copy of the same hierarchy and for the 0CUSTOMER object and nodes give tech names as text also.

  • Hide the last level of a hierarchy in bex

    HI experts,
    In a query I use a hierarchy based on 0account (characteristic based hierarchy, every node is also an account...)only leaves have figures in the cube (meaning no direct posting on nodes).
    This hierarchy doesn't have flat / equal levels, and final accounts are sometimes located on level X, sometimes on level X+1 etc...therefore, I can't use the standard fonctionnality "expand to level X"
    see below a simple exemple
    (in fact my hierarchy contain more than 10 levels):
    level1..|..level2..|..level3
    ..node 1-1     
    .........|.node 1-2 ("R"account)
    .......................|.<b>account</b>
    ..node 2-1 ("R"account)
    .........|.<b>account</b>
    My users want to be able to simply navigate in the hierarchy on specific nodes(which have specific properties through the usage of an navigational attribute used on my 0account characteristic), whitout having to expand to the last level: example the "R" level wich is the level before. Again, this R level resides in different levels of my hierarchy.
    So I have to find a way to stop the expand of the hierarchy to this specific level, hide the levels below(account), but include the amount of the lower levels in this specific specified level ("R").
    If you have any ideas/clues or suggestions on how to resolve this issue (navigational attribute, exits, restricted key figures, hidden columns...)...this would really be much appreciated.
    thanks a lot!
    Ps: I work on BW 3.5
    Message was edited by: Agathe LE LAMER

    Hi Agathe LE LAMER
    I know this thread is a little old now, but I would be interested to know if you had found a way of doing this. I am also trying to supress the lowest level in a hierarchy which are not all the same levels.
    Thanks
    Ben

  • Creating dimension in OMB script with only 1 level and no hierarchy

    Hi all,
    I have created some dimensions in the OWB client, that map straight 1-on-1 to a table. Those dimensions have only 1 level 'TOTAL' and no hierarchies.
    I am trying to create those dimensions using an OMB script, but it seems that when I bind the dimension level to a table, it =expects= me also to bind hierarchy levels to the table! However I have (dont want/need) a hierarchy?!
    The error message is:
    OMB00001: Encountered DIMENSION_KEY at line: 1, column: 2309. Was expecting one of: <EOF>
    The OMB code I have is:
    IMPLEMENTED BY SYSTEM STAR \
    DIMENSION_KEY BOUND TO COLUMN 'DIM_CAUSE_KEY' \
    LEVEL 'TOTAL' BOUND TO TABLE 'DIM_CAUSE' \
    LEVEL_ATTRIBUTE 'DIM_CAUSE_KEY' OF LEVEL 'TOTAL' BOUND TO COLUMN 'DIM_CAUSE_KEY' \
    LEVEL_ATTRIBUTE ...
    LEVEL_ATTRIBUTE ...
    After the LEVEL_ATTRIBUTEs the statement ends, so I say nothing about any hierarchies.
    If anybody could give me a hint, that would be much appreciated!!
    Ed

    It is finally solved...
    The keyword "SYSTEM" in "IMPLEMENTED BY SYSTEM STAR" shoudn't be there...
    Unfortunately I was overlooking that in the oh-so-clear syntax diagram in the OWB API and Scripting Reference..... )-;
    Let's move on.
    Cheers,
    Ed

  • Only last pm_order operation in 0PM_DS04_Q0021 query?

    Hi Experts,
    When I execute query 0PM_DS04_Q0021 - Outstanding Order List,which runs
    over the DSO 0PM_DS04 - Maintenance Orders, Operations and Costs, I
    expect to have actual and planned time by order, but for all operations
    that occur in that PM order.
    I went over some PM orders on IW33 transaction code in R3 system and I
    compared it to query results in Business Explorer Analyzer.
    After a few records I got to think that BW is just geting the actual and planned time for the last operation for that order.
    Can you guve me a hint on how I can solve this?
    Thanks in advance for your help,
    Best Regards,
    André Oliveira

    Hi Experts,
    When I execute query 0PM_DS04_Q0021 - Outstanding Order List,which runs
    over the DSO 0PM_DS04 - Maintenance Orders, Operations and Costs, I
    expect to have actual and planned time by order, but for all operations
    that occur in that PM order.
    I went over some PM orders on IW33 transaction code in R3 system and I
    compared it to query results in Business Explorer Analyzer.
    After a few records I got to think that BW is just geting the actual and planned time for the last operation for that order.
    Can you guve me a hint on how I can solve this?
    Thanks in advance for your help,
    Best Regards,
    André Oliveira

  • Passing values of the column in the last level of a dimension hierarchy.

    My report has two colums
    Column1 (Dimension has a hierarchy)
    Columns2 (Fact with an Aggregation Rule)
    I want to use the drill down facility in column 1 and pass the value in the last level of the hierarchy to navigate to another report. Can someone help me on this?
    [Note: The above is possible when the column that is on the last level of the drill hierarchy is in the main report]

    @ubuntupenguin Thanx for your prompt reply.
    I am currently able to store all the necessary symbols in an array. But, How do I query for multiple symbols in the SQL Query ?
    I have an array symArr[] which consists of all the symbols I need to query from the database. So, How should I write the SQL Query is my question.
    I could have created a string which looks something like this from the symArr[] array:
    XOM,AA,BAC,BB,BBC,....
    But, the problem would be when I try to query these symbols in the php data service using "SELECT * FROM TABLENAME WHERE SYMBOL IN (?)"
    where the variable $symbol is the populated string (XOM,AA,BAC,BB,BBC,.... ). So, to rephrase my question, Could I use SELECT * FROM TABLENAME WHERE SYMBOL IN (?) to query for Multiple symbols or is there a better approach.
    Thanx in advance.
    -Krishna

  • Printing in only last line item printing in main window

    Hi All,
    My requiremnet is to print same data in two blocks for F110 payment cheque
    Iam using 2 main windows to print same data if block exceeds it will go to next page
    iam calling the windows as shown below
    CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            window   = 'MAIN00'
            element  = hlp_ep_element
            function = 'APPEND'
          EXCEPTIONS
            window   = 1
            element  = 2.
        IF sy-subrc EQ 2.
          err_element-fname = t042e-zforn.
          err_element-fenst = 'MAIN00'.
          err_element-elemt = hlp_ep_element.
          err_element-text  = text_525.
          COLLECT err_element.
        ENDIF.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            window   = 'MAIN01'
            element  = hlp_ep_element
            function = 'APPEND'
          EXCEPTIONS
            window   = 1
            element  = 2.
        IF sy-subrc EQ 2.
          err_element-fname = t042e-zforn.
          err_element-fenst = 'MAIN01'.
          err_element-elemt = hlp_ep_element.
          err_element-text  = text_525.
          COLLECT err_element.
        ENDIF.
    Iam getting only last line item printing in main window
    Please provide the inputs.
    Thanks,
    Kamalakar.
    Please use code tags.
    Edited by: Rob Burbank on Nov 25, 2011 11:51 AM

    Hi,
    My requirement was to print same block twice in cheque printing of F110.
    I have used the function module  'WRITE_FORM_LINES' to print more than one line item in secondary window in the script .
    fill the Lines internal table as shown below.
    Example :
        lines-tdformat = 'TM'.
        CONCATENATE regup-xblnr ',,' w_date ',,'  w_bsak-sgtxt ',,' w_gross ',,' w_dis ',,'
        w_net INTO lines-tdline.
    APPEND lines.
    CALL FUNCTION 'WRITE_FORM_LINES'
          EXPORTING
           function                       = 'APPEND'
           header                         =  header_t
           type                           = 'BODY'
           window                         = 'MAIN01'
        IMPORTING
          FROMPAGE                       =
          PENDING_LINES                  =
          TABLES
            lines                          = lines
         EXCEPTIONS
           function                       = 1
           type                           = 2
           unopened                       = 3
           unstarted                      = 4
           window                         = 5
           bad_pageformat_for_print       = 6
           spool_error                    = 7
           codepage                       = 8
           OTHERS                         = 9
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF.

  • IP - Aggregation Level not showing in Query Designer as infoprovider

    Hi guys
    I just started implementing Integragted Planning at a new client. I created an aggregation level to build my input ready query. However this aggregation level is not available as an inprovider in the Query Designer nor is it available under the infocube in RSA1 on which the aggregation has been defined.
    Any suggestions?
    Thanks for your help.
    Ameya Kulkarni

    Hi Mayank
    Good point. But I could not see the aggregation level whatsoever in RSA1. The aggregation level is consistent and activated but does not show in the query designer.
    I was wondering if there is some configuration that I have to do to get the aggregation level available in the query desginer.
    Please let me know.
    Thanks,
    Ameya Kulkarni

  • Need help in SQL query to get only distinct records

    Hi all.
    I am new to oracle SQL and i want to write a query to get only distinct values from 2 tables.
    for example i hade 2 tables table1(employee_id,employee_no,grade) and another table2 with same structure.
    for example data in table1 is
    Employeeid employeeno Grade
    1 101 A
    1 101 B
    1 101 E
    1 101 D
    and data in table 2 is
    Employeeid employeeno Grade
    1 101 A
    1 101 B
    1 101 E
    i want to display only the fourth row like the data that doesnt exist in table2 i,e (1 101 D)
    I had too much records in both tables and i jst want to see the records that is in table 1 not in table 2 only.
    employeeid and employeeno are the same in both tables
    I hope u understand my query. I user left outer join and right outer join bt it displays all the results that and matching and unmatching. I want jst unmatched records.
    Any help is highly Appreciated.
    Thanx in Advance.
    I am using oracle 10G on windows

    Try MINUS:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries004.htm#i2054381
    SQL> -- generating sample data:
    SQL> with t1 as (
      2  select 1 employeeid, 101 employeeno, 'A' grade from dual union
      3  select 1, 101, 'B' from dual union
      4  select 1, 101, 'E' from dual union
      5  select 1, 101, 'D' from dual
      6  )
      7  ,  t2 as (
      8  select 1 employeeid, 101 employeeno, 'A' grade from dual union
      9  select 1, 101, 'B' from dual union
    10  select 1, 101, 'E' from dual
    11  )
    12  --
    13  -- actual query:
    14  --
    15  select employeeid
    16  ,      employeeno
    17  ,      grade
    18  from   t1
    19  minus
    20  select employeeid
    21  ,      employeeno
    22  ,      grade
    23  from   t2;
    EMPLOYEEID EMPLOYEENO G
             1        101 D
    1 row selected.

  • How to get the last transaction in a row in SQL Developer?

    What syntax would I use to get the last transaction of a row in SQL developer?
    The way I have my query set-up currently it is not returning the correct data, here is my current syntax:
    select ssn, max(tran_id), chng_type,tran_id
    from pda_tran
    where ssn = 'xxx-xxx-0011'
    and chng_type = 'C'
    group by ssn, chng_type,tran_id;
    It returns a 'C' chng_type but it is not the last one. when I query on this ssn this is what I get:
    ssn tran_id chng_type
    xxx-xxx-0011 001 A
    xxx-xxx-0011 002 E
    xxx-xxx-0011 003 C
    xxx-xxx-0011 004 S
    xxx-xxx-0011 005 C
    xxx-xxx-0011 006 T
    I only want to return the ssn's with a last transaction chng_type of 'C'. How can I get the correct information returned. Please advise.

    From what I see and read... there is one to many group by
    You wrote
    select ssn, max(tran_id), chng_type,tran_id
    from pda_tran
    where ssn = 'xxx-xxx-0011'
    and chng_type = 'C'
    group by ssn, chng_type,tran_id;
    If you want the max(tran_id), remove it from the "group by"
    select ssn, chng_type, max(tran_id)
    FROM
    (SELECT 'xxx-xxx-0011' ssn, '001' tran_id, 'A' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '002' tran_id, 'E' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '003' tran_id, 'C' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '004' tran_id, 'S' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '005' tran_id, 'C' chng_type FROM DUAL UNION
    SELECT 'xxx-xxx-0011' ssn, '006'tran_id, 'T' chng_type FROM DUAL )
    where ssn = 'xxx-xxx-0011'
    and chng_type = 'C'
    group by ssn, chng_type;

  • Custom Drill from the last level of Hierarchy

    I have a dimension hierarchy STAGE which has five levels L1 -> L2 -> L3 -> L4 -> L5
    and my fact table have 5 measure columns say M1 , M2 , M3 , M4 , M5 along with the dimension columns .
    My requiremetn is to show only the top level hierarchy and one measure column initially:
    L1 -- M1
    now user have to drill from L1 to L5
    L1 L2 M1
    L1 L2L3-- M1
    L1 L2L3--L4-- M1
    L1 L2L3--L4--L5-- M1
    by default when the user comes at the last level of hierarchy or the hyperlink to drill futrter gets disabled.
    Now my requirement is to show the detail report when the user comes at the last level and the there should be a link on it. when the user will clink on the last level link it should open below report :
    L1 L2L3--L4--L5--D1--D2--D3--D4--D5--M1--M2--M3--M4--M5
    D1-D5 are other dimension columns which are connected to Fact Table.
    Any suggestions??

    Abhiiiiiii wrote:
    Navigation is also a problem here since the column is coming coming runtime(after drill).What i told u is to use the navigation option insted of drill. So you need to create five reports each one for the particular hierarchy. and set the navigartion target as next level report in the hierarchy. Yes it is not the optiumum solution. But if you dont want the other two solutions given above you need to go with this only.

  • Showing only a particular level from a hierarchy on a report

    Hi,
    I'm creating a crystal report on top of a BW Bex Query.
    In that BEx query I have a hierarchy on Profit Center with 6 levels, where the first level is the Area, the second one the Country, the third one is Plant, ...
    In my crystal report I only want to see the Areas in a table together with some key figures.
    If I use the Profit Center characteristic on the report, I get all values existing in the hierarchy, so not only the Areas, but also the countries, the plants, ...
    How can I manage to always see the Areas only?
    Lieven

    Lync 2010 doesn’t have the feature natively.
    With Lync Server 2010, by default, the contacts from federated domains are added as External Contacts.
    Lisa Zheng
    TechNet Community Support

  • Get the last query from the current user

    Is there a way to get the last query of the current user, so every query could be log with a database trigger?
    Let's just say I execute:
    DELETE xxxx;
    I tried :
    SELECT T.SQL_TEXT FROM V$SQLAREA T where ADDRESS=(SELECT prev_sql_addr FROM v$session where audsid=userenv('sessionid'));
    But the result of this query is :
    'SELECT T.SQL_TEXT FROM V$SQLAREA T where ADDRESS=(SELECT prev_sql_addr FROM v$session where audsid=userenv('sessionid'))'
    Is there a way to execute a query that would return :
    'DELETE xxxx'
    Thanks

    You could join SQL_ADDR in v$session with ADDRESS in v$sqlarea to determine the SID that executed that SQL statement last. Note that PREV_SQL_ADDR in v$session will indicate the previous SQL he executed. Though you would have to look at these tables very often to get all SQL statements issued. One note here, I think if a different user ran the SAME SQL with just bind var differences the SQL_AREA will only show the last user’s information that executed it.
    BTW - it will show deletes also...

Maybe you are looking for