Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old April 23rd, 2008, 05:42 AM
anunaaya anunaaya is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 1 anunaaya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 43 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old April 27th, 2008, 01:29 AM
visakh16 visakh16 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Location: Trivandrum,Kerala
Posts: 32 visakh16 User rank is Sergeant (500 - 2000 Reputation Level)visakh16 User rank is Sergeant (500 - 2000 Reputation Level)visakh16 User rank is Sergeant (500 - 2000 Reputation Level)visakh16 User rank is Sergeant (500 - 2000 Reputation Level)visakh16 User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 10 h 4 m
Reputation Power: 11
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

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > SQL Server 2000 - Need help to write the query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway