|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
SQL Server 2000 - Need help to write the query
I need help to write a query. The details of which is given below
employee table Empid EmpName EcatID ProjectID 1200 Rama 5 2 1201 Shiva 5 2 1202 arab 6 44 1207 Kumar 3 28 1208 Despande 6 2 1210 Divya 3 50 1230 praveen 1 44 1232 Raghu 1 28 1247 sumitra 1 2 1266 Manoj 1 39 1274 Siddu 2 39 Empskill Table EmpID CourseID SelfRating Evalrating 1201 10 4 - 1202 11 8 7 1202 100 8 - 1200 12 7 7 1207 99 10 9 1207 100 10 8 1207 101 8 8 1207 102 5 5 1207 103 6 4 1207 104 4 4 1274 104 8 8 Result Needed: Empid PMName No Of Subordinates TotalNoofSubjsratedbysubords TotalNoOfEvalRating 1230 praveen 1 2 1 1232 Raghu 1 6 6 1247 sumitra 2 2 1 1266 Manoj 1 1 1 EcatID =1 means he is a Project Manager a PM has a ProjectID, his sub-ordinates have the same ProjectID (thats how you locate them) Thanks Have a nice day ![]() |
|
#2
|
|||
|
|||
|
Code:
SELECT t1.Empid, t1.EmpName, COUNT(DISTINCT t2.Empid) AS [No Of Subordinates], COUNT(SelfRating) AS [TotalNoofSubjsratedbysubords], COUNT(Evalrating) AS [TotalNoOfEvalRating] FROM employee t1 INNER JOIN employee t2 ON t2.ProjectID=t1.ProjectID AND t1.EcatID=1 AND t2.Empid<>t1.Empid INNER JOIN Empskill t3 ON t3.EmpID=t2.EmpID GROUP BY t1.Empid,t1.EmpName |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > SQL Server 2000 - Need help to write the query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|