Get the count of number of people reporting to Manager directly/indirectly

I have the following Manager / Employee hierarchy.
Manager -> employee
A -> B (B is reporting to A)
A -> B -> C (C is reporting to B and B is reporting to A)
A -> B -> C -> D(D is reporting to C and C is reporting to B and B is reporting to A)
How can the get the count of total no of person reporting to A either directly or indirectly.
My count should be like that.
A -> B (count - 1)
A -> B -> C (count - 2)
A -> B -> C -> D (count - 3)
appreciate any inputs..

Hi
You need to run something like:
SELECT ENAME "Employee", CONNECT_BY_ROOT ENAME "Manager",
LEVEL-1 "Pathlen", SYS_CONNECT_BY_PATH(ENAME, '/') "Path"
FROM EMP
WHERE LEVEL > 1
CONNECT BY PRIOR MGR = EMPNO
this is based on the EMP table and connects every employee to their top-level manager
Andy

Similar Messages

  • How do you get  the count of number of  checkbox selected?

    hi,
    plz tell me how do you get the count of number of checkbox selected?

    Not sure what you are doing so I will attempt to answer your question. If have one question which can have multiple answers you have will recieve an array so you have to do getParameterValues("name") and move it into an array.
    If you have multiple questions and only value will be selected do a getParameter("name") on each form element.
    HTH, if not provide more detail.
    J.Clancey

  • How to get the count of PO'S raised by a user

    Hi,
    I have a new requirement whr i am asked to get the count of number of PO'S raised by a particular user in report. Suppose the user raised 10 purchase orders .
    The requirement is when a user name is given it has to give count of 10.
    Where shud i include this,in rows or columns. Please suggest.
    Thanks&Regards,
    Praveen

    Hi Praveen,
    take a look in www.service.sap.com/bi, under old release, for release 2.x you will find an How to that detail how to count occurencies of a Char. Maybe you will find here the solution.
    Ciao.
    Riccardo.

  • How to get the Count of a logic?

    Hi,
    Very new to CRM. I am trying to get the count of "activity start time" that are greater than current time stamp. Count(activity start time) work. I don't know how to add the time stamp condition to this. I can't add this condition as filter.
    Appreciate any responses.
    Thanks

    Raghu,
    Thanks for the help. It works to get the count.
    The problem is, i have some other filters set and can't combine this filter. Here is my scenario:
    get all activities on a contact that have greater than x $ amount as assets. I need to find the number of future appointments for that contact and start time of first pending future appointment. All has to be in one report.
    My columns are for example : contact name, activity start time, end time, subject, next pending appointment start time, total future appointments, some other related fields from contact
    So when I add the filter that you had given, it will not give me all activities. I am able to achieve all this in seperate reports and unnable to get it in single one.
    Thanks,
    GiGi

  • To get the count of records and able to access the column value in a single

    Hi
    Is there any way to get the number of records in the query and access the column values
    e.g
    select count(*)
    from
    (SELECT department, COUNT(*) as "Number of employees"
    FROM employees
    WHERE salary > 25000
    GROUP BY department ) a
    This wil only get the Count, if i want to access each row from the inline view how can i do that.

    Your question is not clear.
    Are you looking for total record count as well as count by department ?
    Something like this?
    SQL>
    SQL> with temp as
      2  (
      3  select 1 dept ,10000 sal from dual union
      4  select 1 dept ,25100 sal from dual union
      5  select 1 dept ,30000 sal from dual union
      6  select 1 dept ,40000 sal from dual union
      7  select 2 dept ,10000 sal from dual union
      8  select 2 dept ,25100 sal from dual union
      9  select 2 dept ,30000 sal from dual union
    10  select 2 dept ,40000 sal from dual )
    11  select count(*) over( partition by 1 ) total_count,dept,
    12  count(*) over(partition by dept) dept_cnt  from temp
    13  where sal>25000;
    TOTAL_COUNT       DEPT   DEPT_CNT
              6          1          3
              6          1          3
              6          1          3
              6          2          3
              6          2          3
              6          2          3
    6 rows selected
    SQL>

  • Get the count of rows in a table control

    Hi Experts,
      How do I get the count of the rows in a table control during run time.
    I am developing a BDC in which I have to check all entries in a table control.
    My requirement is to get the total number of rows in a table control dynamically.
    Thanks
    Kumar

    Hi,
    Use a variable when u r passing the records from the internal table to the screen fields
    and display the same.
    I think this idea may help u.
    And pls explain me ur requirement clearly.
    Refer to the following link this may help u.
    http://sapabapnotes.blogspot.com/2008/03/working-with-ecatt-extended-computer.html
    Reward if helpful.
    Jagadish

  • Use SQL function to get the original order number using the invoice number

    Hi All,
    wondering is someone can help me with this challenge I am having?  Often I need to return the original order numbers that created the resulting invoce.  This is a relatively simple seriese of joins in a query but I am wanting to simplify it using a SQL function that can be referenced each time easily from with in the SELECT statement.  the code i currently have is:
    Use SQL function to get the original order number using the invoice number
    CREATE FUNCTION dbo.fnOrdersThatMakeInvoice(@InvNum int)
    RETURNS nvarchar(200)
    AS
    BEGIN
    DECLARE @OrderList nvarchar(200)
    SET @OrderList = ''
    SELECT @OrderList = @OrderList + (cast(T6.DocNum AS nvarchar(10)) + ' ')
    FROM  OINV AS T1 INNER JOIN
          INV1 AS T2 ON T1.DocEntry = T2.DocEntry INNER JOIN
          DLN1 AS T4 ON T2.BaseEntry = T4.DocEntry AND T2.BaseLine = T4.LineNum INNER JOIN
          RDR1 AS T5 ON T4.BaseEntry = T5.DocEntry AND T4.BaseLine = T5.LineNum INNER JOIN
          ORDR AS T6 ON T5.DocEntry = T6.DocEntry
    WHERE T1.DocNum = @InvNum
    RETURN @OrderList 
    END
    it is run by the following query:
    Select T1.DocNum, dbo.fnOrdersThatMakeInvoice(T1.DocNum)
    From OINV T1
    Where T1.DocNum = 'your invoice number here'
    The issue is that this returns the order number for all of the lines in the invoice.  Only want to see the summary of the order numbers.  ie if 3 orders were used to make a 20 line inovice I only want to see the 3 order numbers retuned in the field.
    If this was a simple reporting SELECT query I would use SELECT DISTINCT.  But I can't do that.
    Any ideas?
    Thanks,
    Mike

    Thanks Gordon,
    I am trying to get away from the massive table access list everytime I write a query where I need to access the original order number of the invoice.  However, I have managed to solve my own problem with a GROUP BY statement!
    Others may be interested so, the code is this:
    CREATE FUNCTION dbo.fnOrdersThatMakeInvoice(@InvNum int)
    RETURNS nvarchar(200)
    AS
    BEGIN
    DECLARE @OrderList nvarchar(200)
    SET @OrderList = ''
    SELECT @OrderList = @OrderList + (cast(T6.DocNum AS nvarchar(10)) + ' ')
    FROM  OINV AS T1 INNER JOIN
          INV1 AS T2 ON T1.DocEntry = T2.DocEntry INNER JOIN
          DLN1 AS T4 ON T2.BaseEntry = T4.DocEntry AND T2.BaseLine = T4.LineNum INNER JOIN
          RDR1 AS T5 ON T4.BaseEntry = T5.DocEntry AND T4.BaseLine = T5.LineNum INNER JOIN
          ORDR AS T6 ON T5.DocEntry = T6.DocEntry
    WHERE T1.DocNum = @InvNum
    GROUP BY T6.DocNum
    RETURN @OrderList 
    END
    and to call it use this:
    Select T1.DocNum, dbo.fnOrdersThatMakeInvoice(T1.DocNum)
    From OINV T1
    Where T1.DocNum = 'your invoice number'

  • How to get the count of customers

    Hi all,
    We have a fact table, AR_F to which the dimensions Party_D and Fin_D are connected. Party-org_d is inturn connected to Party_d.
    party_org_D contains details of customers like Customer name and customer ID (Number)
    Fin_D contains ratings (Both -ve and +ve) of each customer.
    the rating range is as follows,
    good rating : >0
    OK Rating: Between 0 and -1.5
    Bad Rating: <-1.5
    Now i need to get the count of all customers falling in each range as separate measures.
    Kindly help me get a solution for this.
    Thank you.

    Hi,
    Try this....
    col 1
    case when Fin_D.ratings > 0 then 'Good'
    when Fin_D.ratings >= -1.5 and Fin_D.ratings <= 0 then 'Ok'
    when Fin_D.ratings < -1.5 then 'Bad' end
    col 2
    case when (case when Fin_D.ratings > 0 then 'Good'
    when Fin_D.ratings >= -1.5 and Fin_D.ratings <= 0 then 'Ok'
    when Fin_D.ratings < -1.5 then 'Bad' end)='Good' then count(customer_id)
    when (case when Fin_D.ratings > 0 then 'Good'
    when Fin_D.ratings >= -1.5 and Fin_D.ratings <= 0 then 'Ok'
    when Fin_D.ratings < -1.5 then 'Bad' end)='Ok' then count(customer_id)
    when (case when Fin_D.ratings > 0 then 'Good'
    when Fin_D.ratings >= -1.5 and Fin_D.ratings <= 0 then 'Ok'
    when Fin_D.ratings < -1.5 then 'Bad' end)='Bad' then count(customer_id)
    end
    hope helps........

  • How to get the count of all the entries in the DB?

    I want to know the way getting the count of the entries in a DB. Not using cursor to visit all entries and record the count.
    Message was edited by:
    user633842

    Hello,
    Yes, depending on the type of database you are using, the
    following statistics from DB->stat, look like what you want.
    For Hash databases:
    hash_ndata;
    The number of key/data pairs in the database. I
    For Btree databases:
    bt_ndata;
    For the Btree Access Method, the number of key/data pairs
    in the database.
    For the Recno Access Method, the number of records in
    the database.
    For Queue databases:
    qs_ndata;
    The number of records in the database.
    Additional details are at:
    http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/db_stat.html
    Thanks,
    Sandra

  • How to get the 4 digit number associated with a SAP icon ( ICON_MAIL )

    Hi Friends,
                   Could anyone please tell me how to get the 4 digit number associated with a SAP icon ( ICON_MAIL ).
                   eg: - For ICON_GREEN_LIGHT the four digit id code is '@08@' (which you can get from ICON table )and the associated 4 digit number is'1003'.
                  Similarly I want to get the 4 digit number for ICON_MAIL(e-mail icon)
    <b><REMOVED BY MODERATOR></b>
    Ashiq
    Message was edited by:
            Alvaro Tejada Galindo

    You can use this report...It's not mine...
    REPORT zdummy_atg_2.
    TABLES: ICON.
    INCLUDE <ICON>.
    FIELD-SYMBOLS: <F>.
    SELECT * FROM ICON.
       ASSIGN (ICON-NAME) TO <F>.
       WRITE:   /(5) <F>, 20 '@',21 ICON-ID+1(2),23 '@',ICON-OLENG,
                ICON-BUTTON,ICON-STATUS,ICON-MESSAGE,ICON-FUNCTION,
                ICON-NAME.
    ENDSELECT.
    Greetings,
    Blag.

  • How to get the spool request number ?

    Hi All,
    I am working on a smart-forms. I am using a custom transaction to print these smartforms. When I execute
    the transaction the print screen comes where I can do
    print preview or print.
    Now to convert this Smart Form to PDF I need to know the spool request number to use in the report called RSTXPDFT5.
    How do I get the spool request number ?
    Do I need to do some changes in spool control options of print screens to get the spool request number or something else ?
    Please let me know.
    Answers will be awarded...
    Tushar

    Hi,
    You will get the spool no. in the parameter "job_output_info" after calling the smartform function module in print program. The spool ids of the prints is stored in table job_output_info-SPOOLIDS.
    Regards,
    Gagan

  • Getting the count of records in a cursor

    Hi,
    How can I get the count of records satisfying a conditin in a cursor.
    This is the code that I have written. Please tell me where I am going wrong.
    declare
    cursor c is
    select * from Details where Name like 'M%';
    rec number;
    r c%rowtype;
    begin
    for r in c
    loop
    rec:=rec+1;
    end loop;
    dbms_output.put_line(rec);
    end;
    Thanks in advance

    Hi,
    You have to initialize the rec variable.
    declare
    cursor c is
    select * from Details where Name like 'M%';
    rec number :=0;
    r c%rowtype;
    begin
    for r in c
    loop
    rec:=rec+1;
    end loop;
    dbms_output.put_line(rec);
    end;
    You can also use the %ROWCOUNT attribute.
    Regards

  • SQ01 - SAP List Viewer - Ability to get the count of the output records

    Hello All,
    I have a problem with the SAP List Viewer output for an SAP Query.
    I have created a SAP query (SQ01) for a table. Its a basic query that queries on just one table (VTBFHA)
    When I run the query, for the output in the SAP List Viewer (ALV) format, Could anyone kindly help me figure out how to get the count of the number of records displayed in the output?
    For Eg: when we run the T code SE16, It gives us the number of records displayed in the output.
    Similarly, does anyone know if there is a way I could display the count of the number of records displayed in the output of the SQ01 query?
    I have tried checking the "Counter" in the basic list tab, but it does not give me the count.
    Any help will be greatly appreciated
    Thanks
    Subhani

    Yes there is a solution. Follow these steps
    Select your query
    Hit the button InfoSet Query
    Go to Edit->Settings->
    Check the box "Count in the Output list" in the Output tab
    Hit Save
    In pop up box select the user group
    hit enter
    Hit the back arrow (F3)
    now Execute the query
    You should be able to see the count in the output.
    The count will appear on the right most column of the output. If it does not go to the "Change layout" option and make sure it is part of the "Displayed columns list".
    Regards

  • Get the current pageno at runtime in Report 6i

    Hi to everybody,
    I wish to know how can i get the current pageno at runtime in report 6i ,
    i want to display data at end page of the report on a condition that it is the last page of the report. i can get the last page but not the current page no at runtime.

    Take a look into SRW.GET_PAGE_NUM. You can use this in format trigger and It will return you current page number.

  • Getting the count of DISTINCT of several columns

    How can i get the count of DISTINCT of several columns?
    SQL> select count(distinct ename) from emp;
    COUNT(DISTINCTENAME)
                      14
    SQL> select count(distinct ename, job) from emp;
    select count(distinct ename, job) from emp
    ERROR at line 1:
    ORA-00909: invalid number of arguments

    Hello,
    You should separate them out like this
    select count(distinct ename), count(distinct job) from emp;Regards

Maybe you are looking for

  • Need help in using a case statement in expression operator

    Hi All, I am using OWB version 10.2.0.1.0. My requirement is to add a new column called call _zone_key in expression operator and map it to the target table. I need to use the below expression for populating call_zone_key values Expression: case when

  • Adobe reader is not opening

    ATTACHMENTS OF MY MAIL OFTEN COMES WITH ADOBE READER. IT IS NOT FUNCTIONING AND OPENING BECAUSE MOZILLA FIREFOXDO NOT PERMIT . IS IT SO . PLEASE PERMIT

  • Issue in Delivery Line Item through VL01N

    Hi, During Delivery creation through VL01N, in Line Item details under Financial Processing Tab, Cost Center is showing as non-changable... We cann't enter any value in this field.. We have two options-- 1. By make the field as changable, so that we

  • Scratchy, distorted, garbled sound from MP3s files

    I'm having really horrible scratchy, distorted, garbled sound from MP3 files. AAC encoded files play extremely clearly on iTunes 10.5

  • Multiple Channels Agilent 2000 3000-x

    I am incredibly new to Labview, so please bare with me here. I am trying to modify existing code to record data from two channels of an osciloscope. I have been searching the internet high and low for a solution, but I haven't found anything. I have