If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > SQL Question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-07-03, 12:20
rajeev_k_menon rajeev_k_menon is offline
Registered User
 
Join Date: Oct 2003
Posts: 1
Question 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
Reply With Quote
  #2 (permalink)  
Old 10-08-03, 01:05
neelamchalam neelamchalam is offline
Registered User
 
Join Date: Jul 2003
Location: india
Posts: 15
Re: SQL Question

Quote:
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On