Query for Supervisor Hierarchy for top most manager

Hi,
I have requirement where I have to start from one employee and move up to top-most supervisor of that employee:
For example starting from Employee ABC and moving to supervisor3 through supervisor hierarachy.
Employee ABC
Supervisor1*
Supervisor2*
Supervisor3*
Can anyone help me in constructing such query.
Regards,
Salman Ahmad

The linked query is to find a loop in the Supervisor hierarchy top down.
The SQL here will display the current supervisor hierarchy for a specified subordinate bottom to top.
select level, rpad(' ',level*2)||paa.person_id, pap.first_name, pap.last_name
from per_all_assignments_f paa
join per_all_people_f pap
on paa.person_id = pap.person_id
and sysdate between pap.effective_start_date and pap.effective_end_date
where sysdate between paa.effective_start_date and paa.effective_end_date
start with paa.person_id = :PersonID
connect by paa.person_id = prior paa.supervisor_id
and sysdate between prior paa.effective_start_date and prior paa.effective_end_date;

Similar Messages

  • Oracle query for top two salary of each group departmentwise

    oracle query for top two salary departmentwise

    sigh...
    But anyway,
    Top-n queries:
    http://www.oracle.com/technology/oramag/oracle/07-jan/o17asktom.html
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2853107469873
    and ofcourse lots of 'em here on OTN...

  • How to get Top most Manager in Org. Structure

    Hi Experts,
          I have an Organization Structure like the following:
                      [0]  MAIN ORG. UNIT
                               MANAGER9           
                              [1]  SUB ORG. UNIT1
                                     Manager1
                                     [1.1] Department1
                                               Manager2
                                               Manager3
                                               Supervisor1
                                               Supervisor2
                              [2]  SUB ORG. UNIT2
                                     Manager6
                                     [2.1] Department2
                                              Manager4
                                              Manager5
                                              Supervisor3
                                              Supervisor4
    1. I want to get the top most manager in the org. structure by looping the org. structure in workflow.
                            Here MANAGER9!!
    2. How can i get Manager1 by using the same.
    Waiting for your valuable Answer
    Thanks
    Regards
    Nizamudeen SM
    Edited by: Nizamudeen SM on Aug 26, 2008 4:08 PM

    These are the paramters to pass ..
    CALL FUNCTION 'RH_STRUC_GET'
            EXPORTING
              act_otype      = c_o
              act_objid       = w_orgunitid
              act_wegid      = 'ORGCHART'
              act_plvar        = '01'
              act_begda      = sy-datum
              act_endda      = '99991231'
            TABLES
              result_tab     = t_restab
              result_objec   = t_resobj
              result_struc   = t_reslt
            EXCEPTIONS
              no_plvar_found = 1
              no_entry_found = 2
              OTHERS         = 3.
          IF sy-subrc NE 0.
          ENDIF.
    It is not the orgunit id should be passed hear in your case it is manin orgunit ..so that it picksup the managers of child Orgunit as well.

  • SQL Query for TOP 10 Average CPU

    Have a SCOM Report request for a line graph showing top 10 average CPU for a group of servers. I have a query that will show all of the servers in a group for the last day, with the average CPU by hour. How can I extend the SQL query to only select the TOP
    10 average CPU from the group? Here is the Query I have:
    SELECT
    vPerf.DateTime,
    vPerf.SampleCount,
    cast(vPerf.AverageValue as numeric(10,2)) as AverageCPU,
    vPerformanceRuleInstance.InstanceName,
    vManagedEntity.Path,
    vPerformanceRule.ObjectName,
     vPerformanceRule.CounterName
    FROM Perf.vPerfHourly AS vPerf INNER JOIN
     vPerformanceRuleInstance ON vPerformanceRuleInstance.PerformanceRuleInstanceRowId = vPerf.PerformanceRuleInstanceRowId INNER JOIN
     vManagedEntity ON vPerf.ManagedEntityRowId = vManagedEntity.ManagedEntityRowId INNER JOIN
     vPerformanceRule ON vPerformanceRuleInstance.RuleRowId = vPerformanceRule.RuleRowId
    WHERE
    vPerf.DateTime  >= DATEADD(Day, -1, GetDate())
    AND vPerformanceRule.ObjectName like '%Processor Information%'
    AND vPerformanceRuleInstance.InstanceName = '_Total'
    AND (vPerformanceRule.CounterName IN ('% Processor Time'))
    AND (vManagedEntity.Path IN (SELECT dbo.vManagedEntity.Name
    FROM dbo.vManagedEntity INNER JOIN
    dbo.vRelationship On dbo.vManagedEntity.ManagedEntityRowId = dbo.vRelationship.TargetManagedEntityRowId INNER JOIN
    dbo.vManagedEntity As CompGroup On dbo.vRelationship.SourcemanagedEntityRowId = CompGroup.ManagedEntityRowId
    WHERE CompGroup.DisplayName = 'bemis ibb prod'
    ORDER BY path, vPerf.DateTime
    Results
    DateTime
    SampleCount
    AverageCPU
    InstanceName
    Path
    ObjectName
    CounterName
    2/26/15 3:00 PM
    2
    1.98
    _Total
    servername.corp.com
    Processor Information
    % Processor Time
    2/26/15 4:00 PM
    2
    2.09
    _Total
    servername.corp.com
    Processor Information
    % Processor Time
    2/26/15 5:00 PM
    2
    1.72
    _Total
    servername.corp.com
    Processor Information
    % Processor Time
    2/26/15 6:00 PM
    2
    1.83
    _Total
    servername.corp.com
    Processor Information
    % Processor Time
    Thanks in Advance!
    Mike Hanlon

    Hi 
    Sql Query
    SELECT TOP 10
    vPerf.DateTime,
    vPerf.SampleCount, 
    cast(vPerf.AverageValue as numeric(10,2)) as AverageCPU,
    vPerformanceRuleInstance.InstanceName, 
    vManagedEntity.Path, 
    vPerformanceRule.ObjectName, 
     vPerformanceRule.CounterName
    FROM Perf.vPerfHourly AS vPerf INNER JOIN
     vPerformanceRuleInstance ON vPerformanceRuleInstance.PerformanceRuleInstanceRowId = vPerf.PerformanceRuleInstanceRowId
    INNER JOIN
     vManagedEntity ON vPerf.ManagedEntityRowId = vManagedEntity.ManagedEntityRowId INNER JOIN
     vPerformanceRule ON vPerformanceRuleInstance.RuleRowId = vPerformanceRule.RuleRowId 
    WHERE 
    vPerf.DateTime  >= DATEADD(Day, -1, GetDate())
    AND vPerformanceRule.ObjectName like '%Processor Information%'
    AND vPerformanceRuleInstance.InstanceName = '_Total'
    AND (vPerformanceRule.CounterName IN ('% Processor Time'))
    AND (vManagedEntity.Path IN (SELECT dbo.vManagedEntity.Name
    FROM dbo.vManagedEntity INNER JOIN
    dbo.vRelationship On dbo.vManagedEntity.ManagedEntityRowId = dbo.vRelationship.TargetManagedEntityRowId INNER
    JOIN
    dbo.vManagedEntity As CompGroup On dbo.vRelationship.SourcemanagedEntityRowId = CompGroup.ManagedEntityRowId
    WHERE CompGroup.DisplayName = 'bemis ibb prod'
    ORDER BY path, vPerf.DateTime
    Regards
    sridhar v

  • Query for top 5 items

    Hi All,
    Looking for a query that would return the top 5 sales items along with sales values, between a date range
    Thanks
    Ranjit Krishnan

    Hi,
    You may try this if Credit Memos do not need to be included:
    SELECT TOP 5 T1.ItemCode, MAX(T1.Dscription) as 'Item Description',  SUM(T1.LineTotal) as 'Amount(LC)'
    FROM dbo.OINV T0
    INNER JOIN dbo.INV1 T1 ON T1.DocENtry = T0.DocENtry
    WHERE t0.docdate >= [%0\] and t0.docdate <= [%1\] AND t0.doctype = 'I'
    GROUP BY T1.ItemCode
    Order by SUM(T1.LineTotal) DESC
    Thanks,
    Gordon

  • Standard Query for Top 10 queries and Users

    Hi Experts,
    Is there any query which gives the details like ,
    1. Top 10 queries executed in a month
    2. Top 10 users ( By no of queries executed )
    Regards,
    Bhadri M.

    1. Top 10 queries executed in a month
    Use Query 0TCT_MCA1_Q0142.
    In this report you will have to filter variable BI Object to Queries and also it gives stats for the last 30 days, you have have to remove the SAP User exit variable in case you do not want to use the 30 days option. And then you will have to define Condition for Top 10.
    2. Top 10 users ( By no of queries executed )
    Use Query 0TCT_MCA1_Q0141.
    Similarly you have to modify this query.
    -Neelesh

  • Query for top 10 selling products and their current stock

    Hi ppl
    I am using the sales overview cube 0SD_C03 to get top 10 selling products. What I want is to get the current stock available of the top 10 products from Material Stocks/Movements cube 0IC_C03. From what I know, we have to make a multiprovider to get this information. Can anyone guide me how to go about it?

    Hello Javed,
                         You can use Replacement path for this.
    1.Create a report for Top 10 Products in InfoCube 0SD_C03 - Exampls Report A
    2.Create another report with Stock and use a variable for Product with processing type replacement path in InfoCube0IC_C03 - Example Report B
    3. In Report B and assing the Report A to this variable.
    When you execute the Report B it will execute the Report A in background and displays it in Report B.
    Hope it helps,
    thanks
    Chandran

  • MDX Query for Top 10 in SSAS Project

    Hi Guys,
    Please I need an MDX query that will help me calculate Top 10 inside the SSAS project.
    Your help will be greatly appreciated.
    Thanks
    me

    Hi,
    I know nothing about PowerView and PerformancePoint Server but I played with Excel and I am able to use the named set I created. Here are the steps which I followed.
    1 - Create the named set. Remember... this name set appears inside the dimension which you use as the first parameter inside TOPCOUNT function.  
    2 - Deploy the cube and perform a process full.
    3 - Navigate to PowerPivot ribbon and click on PowerPivot Window.
    4 - Choose From Database > From Analysis Services or PowerPivot. Specify the necessary SSAS server credentials and connect to the Cube which you are interested.
    When it comes to the MDX query design window you construct your MDX code in SSMS and copy that code. You also can use the design mode as well. In this case you have to toggle the "design mode" option and enter to manual mode which you can type
    your MDX code. Here is a screenshot of that.
    5 - Validate your query and click Finish. Once the data is in you can create your power pivot report. Here is an example.
    I hope this helps to troubleshoot your issue.
    Best regards...
    Chandima Lakmal Fonseka

  • Custom report for TOP 10 CPU Utilization machines from any group in aggregation last seven days

    I want to create a custom report that contain list of TOP CPU Utilization of machines form any group.This report is create on last 7 days CPU utilization of all machine from a group.
    What  should be query for this report.

    Hi,
    Please refer to the links below:
    SQL Query for TOP 10 Average CPU
    https://social.technet.microsoft.com/Forums/systemcenter/en-US/8d9a2d0d-8761-4d1f-b194-b24aa65172e1/sql-query-for-top-10-average-cpu?forum=operationsmanagerreporting
    How to use Report Builder to create custom reports in SCOM 2007
    http://www.systemcentercentral.com/how-to-use-report-builder-to-create-custom-reports-in-scom-2007/
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]

  • Adhoc query for Training & Event mgmt

    Hi,
    Can anybody guide me for design the adhoc query for training & event management. I needto extract data upto attende level from a particular infoset.
    Thanks
    Dadarao.

    Hi,
    I have got a query in AD-HOC query.
    After creating the Adhoc query using the join table functionality the resulting adhoc query does not results any out put.
    What I have done is :
    1.Created a user group through SQ03
    2.Attched user to My user group
    3.Created an infoset using join table functionality(SQ02).
    4.Saved and generated the infoset
    5.Added the user group to the infoset and than run the ADHOC query.
    The table I have used to join is all PA table (For test pupose)
    Though the purpose of the custom infoset is to join PA,OM and E rec infotypes, for testing purpose I have joined only PA infotypes.
    Result:The adhoc query does not gives any out put instead it says no data could be read.
    Could you please tell what else I need to do so that the custom infosets gives an out put.
    Will greatly appreciate your help.
    Thanks and best regards
    Rajeev

  • Query for Order recomendation from MRP.

    Good evening,
    Recommendations are saved for the Production and Purchase Order after MRP is done.  New Production and/or Purchase Orders are created in Planned stages.  We need a query for the Alert Management to the users for the new Orders created.
    Please can anyone guide and help me.
    thank you.

    Hi,
    Welcome you post on the forum.
    Try this for production order:
    SELECT T0.DocNum, T0.ItemCode FROM OWOR T0
    WHERE T0.OriginType = 'R' AND DateDiff(dd,T0.DocDate,GetDate())=0
    Thanks,
    Gordon
    Good Morning Sir,
    Thanks for your message, guidance and support for the query.
    The query for the alert for Production is working fine, we just changed the DocDate to PostDate as the Production Order, Posting date is as PostDate.
    We tried to change the OWOR to OPOR and the Origin type to T0.Comments='Origin :MRP' and tried for Purchase Order, but the alert is not visible.  Would it be ok, that we create an UDF and try the same?.
    thanks and warm regards.

  • Top 20 (details) for top 20 (summary)

    I have a query whose structure is somewhat like:
    select distinct c,t, cu, s, somenumber, all
    from
    (-- outermost
        SELECT 
        t, c, cu,somenumber,all,c_cd, cname
        FROM ...
        where ...
        and c_cd in 
                       (--1st
                        select c_cd from
                            (--2nd
                            select c_cd, name,somenumber,ALL
                            from
                            (-- 3rd
                               SELECT c_cdc cname,
                               ...m,
                                sum(o) ALL
                                FROM
                                where
                                group by c_cd, cname
                                ORDER BY somenumber desc
                            )-- 3rd
    where rownum <=20
                            )-- 2nd
                            )-- 1st                    
    group by t,cu, c_cd, cname
    order by somenumber desc
    )-- outermost
    where rownum <=20 -- this wont return top 20 per c_cd because no group by. How can I get top 20 details (outer query) for top 20 summary c_cd's (summary inner query)
    order by somenumber desc what I am trying to do here is:
    the inner query returns 20 c_cd's. The outer (main) query returns to 20 details (by somenumber) for that 10 cd_s.
    However I am not able to say that give me the top 10 details for the give 20 c_cd's.
    It is like give me top 20 based on somenumber group by the given top 20 c_cd's.
    Any idea how can I modify my query and get the results?

    Is there some reason you can't accomplish what you want, far more easily, using analytic functions?
    http://tahiti.oracle.com
    http://asktom.oracle.com
    http://www.psoug.org/library.html

  • Query for HRMS supervisor hierarchy

    I need to list all people in a given person's supervisor hierarchy. The following query returns me a person's direct manager and whether or not that person is an officer. I've tried using connect by to return all supervisors in the person's hierarchy but cannot get it working thus far. Any idea what I am doing wrong with the connect by?
    SELECT papf.employee_number,
    papf.person_id,
    papf.full_name,
    ppg.segment1 officer_flag,
    NVL(spapf.full_name,'NONE') supervisor_name,
    spapf.person_id,
    spapf.email_address
    FROM per_all_people_f papf,
    per_all_assignments_f paaf,
    pay_people_groups ppg,
    per_all_people_f spapf
    WHERE papf.person_id = :person_id
    AND papf.person_id = paaf.person_id
    AND SYSDATE BETWEEN papf.effective_start_date AND papf.effective_end_date
    AND SYSDATE BETWEEN paaf.effective_start_date AND paaf.effective_end_date
    AND SYSDATE BETWEEN spapf.effective_start_date(+) AND spapf.effective_end_date(+)
    AND apps.xxx_person_type.is_employee(SYSDATE, papf.person_id) = 'TRUE'
    AND paaf.assignment_type in ('E','C')
    AND paaf.supervisor_id = spapf.person_id ( + )
    AND paaf.people_group_id = ppg.people_group_id
    AND paaf.primary_flag = 'Y'
    --order by to_number(employee_number)
    --CONNECT BY PRIOR paaf.supervisor_id = spapf.person_id
    ;

    Thanks for the response.
    I tried the following using a variety of employee numbers in the hierarchy, sysdate and level < 100. I got ORA-01436: CONNECT BY loop in user data and it seemed to think the reference to per_all_assignments_f to be the issue, but not sure.
    What am I doing wrong?
    SELECT papf.employee_number,
    papf.person_id,
    papf.full_name,
    ppg.segment1 officer_flag, --executive flag for officers (Y is officer, N is not)
    NVL(spapf.full_name,'NONE') supervisor_name,
    spapf.person_id supv_person_id
    FROM per_all_people_f papf,
    per_all_people_f spapf,
    per_all_assignments_f paaf,
    pay_people_groups ppg
    WHERE papf.person_id = paaf.person_id
    AND :p_eff_date BETWEEN papf.effective_start_date AND papf.effective_end_date
    AND :p_eff_date BETWEEN paaf.effective_start_date AND paaf.effective_end_date
    AND :p_eff_date BETWEEN spapf.effective_start_date(+) AND spapf.effective_end_date(+)
    AND xxx_person_type.is_employee(:p_eff_date, papf.person_id) = 'TRUE'
    AND paaf.assignment_type in ('E','C')
    AND paaf.supervisor_id = spapf.person_id (+)
    AND paaf.people_group_id = ppg.people_group_id
    AND paaf.primary_flag = 'Y'
    START WITH papf.employee_number = :p_emp_num --emp num of employee or top level supervisor?
    CONNECT BY PRIOR spapf.employee_number = papf.employee_number AND LEVEL < :p_level
    ORDER BY 1 DESC
    ;

  • Dashboard for top Management.

    Dear all,
    i have to design dashboard for top management.my query is how i can decide that what general information a top management requires to be displayed on dashboardas i have no clear requirements...and am a fresher..i will give points if i got help on the same.

    Hi gaurav,
    Manager's Dashboard provides near-real-time performance metrics, enabling you to monitor plant operations at a glance. These user-selected metrics let you drill-down into supporting enterprise data to quickly understand manufacturing and operational activities throughout your plant. With access to key analytical data, you can then avoid or resolve problems by quickly taking corrective action.
    Some of the features and benefits of dashboards are
    Revenue Managementu2014provide metrics on future cash receipts and overall revenue performance
    Customer Shipment Performanceu2014display fulfillment information
    Manufacturing Performanceu2014get data on your manufacturing operations
    Inventory Management Effectivenessu2014provide summary information on inventory turns
    Supplier Performanceu2014provide summary and detailed information on supplier performance
    Cash and Capital Managementu2014display cash flow data
    So depending on these you can decide which content your organization wants, as your manager also what are the things he needs everyday for analysis. Also use the concept of MIS and EIS.
    Hope it will help.
    Reward Point if helpful.
    Thanks,
    Raja

  • How to find top utilized query for last two months in oem

    how to find top utilized query for last two months in oracle enterprise manager?

    Can you mark the thread as Helpful  and once marked the information can be reviewed by other customer for similar queries
    Regards
    Krishnan

Maybe you are looking for

  • Text options -- skew?

    Hi there This is just a very quick question really - is there an option (which I am sure there is but i just cant find it) to do the equivalent of a transform skew in photoshop? I would like to apply this to some text... Thanks, T xXx

  • Firmware Upgrade for Actiontec GT704WG Rev. B Router

    How do I find the firmware upgrade for the Actiontec GT704WG Rev. B Router?  Almost everytime I try to get onto the internet, I have to run the troubleshooter because there is no connection and the final diagnosis is that "The default gateway is unav

  • How do you change the Tree Component Icons?

    Hi, I have been trying to get to grips with the tree component. I want to customise it so that I can have a different icon for each different link. E.g. a QT logo for a video etc. If no valuse is found for the 'icon' attribute it will just display th

  • NEW MACMINI LEFT IN SLEEP MODE HAS TO BE RESTARTED 3 0R 4 TIMES A DAY

    Help. I have a new macmini 2ghz intel with 2gb memory. Quite often when I return to it after an hour or so of sleep mode, I get a message on the screen advising I must shut down by turning off and restarting. There are no non apple items connected an

  • Producer consumers questions

    I am developing an application that reads and processes serial data from a prototype device.  The data is transferred from my device at 160 Hz and is comprised of about 200 bytes of data. Each data packet has header, data, and checksum bytes.  A illu