469,138 Members | 1,343 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,138 developers. It's quick & easy.

count the no of emp under GPM list that emp with mgrid

Hi

MY table contains

empid empname mgrid mgrname Department


1 suneetha 2 Rama MTS
2 Rama 5 Venkat PM
3 Kiran NULL NULL GPM
4 Hema 2 Rama NULL
5 Venkat 3 Kiran SPM
NULL NULL NULL NULL MTS



i want to find number of employees under GPM

count the number of emp under GPM list that emp with mgrid


Thank you
Mar 13 '08 #1
2 869
srinit
43
Can you tell me your requirement clearly..and post the code what you tried

cheers..//
Mar 13 '08 #2
deepuv04
227 Expert 100+
Try the following
Expand|Select|Wrap|Line Numbers
  1. with cte as
  2. (
  3.     select empid, empname, mgrid, mgrname ,Department
  4.     from Table_Name where empid = (select distinct empid from Table_Name where department= 'GPM' ) 
  5.     union all
  6.     select O.empid, O.empname, O.mgrid, O.mgrname, O.Department
  7.     from Table_Name O, Cte C WHERE O.mgrid   = C.empid 
  8. )
  9. SELECT COUNT(empid) FROM CTE
  10.  
  11.  
Mar 13 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Bart Nessux | last post: by
22 posts views Thread by Ling Lee | last post: by
2 posts views Thread by bearophileHUGS | last post: by
3 posts views Thread by Auddog | last post: by
26 posts views Thread by Ping | last post: by
4 posts views Thread by =?Utf-8?B?a2s=?= | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.