Results 1 to 2 of 2

Thread: SQL Question

  1. #1
    Join Date
    Oct 2003
    Posts
    1

    Question Unanswered: SQL Question

    Hi,

    I'm new to queries. If you could help me with the following query, that'll be great:

    Table (Company) has the following columns:
    EID, EmployeeName, ManagerID

    qtn.) Write a query which gives all the managers names and the number of employees working under him

    Thanks in advance,
    Rajeev

  2. #2
    Join Date
    Jul 2003
    Location
    india
    Posts
    15

    Re: SQL Question

    Originally posted by rajeev_k_menon
    Hi,

    I'm new to queries. If you could help me with the following query, that'll be great:

    Table (Company) has the following columns:
    EID, EmployeeName, ManagerID

    qtn.) Write a query which gives all the managers names and the number of employees working under him

    Thanks in advance,
    Rajeev


    hi rajeev try with this

    select managerid , count( eid) as numofemps from company group by managerid;

    sample data
    EID EMPNAME MANAGERID

    ----------- ---------- -----------

    9 emp9 3

    8 emp8 3

    18 emp18 3

    1 emp1 2

    11 emp11 2

    2 emp2 9

    22 emp22 9

    42 emp42 9

    100 emp100 2

    101 emp101 2

    103 emp103 3

    107 emp107 3

    117 emp117 3


    Result data

    MANAGERID NUMOFEMPS

    ----------- -----------

    2 4

    3 6

    9 3
    Regards,
    Chalam N

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •