B
Becky
hello to all
I'd like to run the following SQL as stacked queries, so that I can compare
the executiom times for each. The 'inner' SELECT find the top 3 scoring
employees from each Org. The 'outer' SELECT uses these results to pick the
Org with the highest total score.
SELECT TOP 1 Q1.OrgID, Q1.OrgName, Sum(Q1.Score) AS Total
FROM qryEmp AS Q1
WHERE (((Q1.EmpID) In ((
SELECT Top 3 Q2.EmpID
FROM [qryEmp] As Q2
WHERE (Q2.OrgID = Q1.OrgID)
ORDER BY Score DESC, EmpID
))
))
GROUP BY Q1.OrgID, Q1.OrgName
ORDER BY Sum(Q1.Score) DESC , Q1.OrgName;
I've turned the 'inner' SELECT in a saved query (qryQ2), but I'm having
trouble with the 'outer' query. Any clues? I'm guessing I don't know how to
write the IN(???).
much thanks
Becky
I'd like to run the following SQL as stacked queries, so that I can compare
the executiom times for each. The 'inner' SELECT find the top 3 scoring
employees from each Org. The 'outer' SELECT uses these results to pick the
Org with the highest total score.
SELECT TOP 1 Q1.OrgID, Q1.OrgName, Sum(Q1.Score) AS Total
FROM qryEmp AS Q1
WHERE (((Q1.EmpID) In ((
SELECT Top 3 Q2.EmpID
FROM [qryEmp] As Q2
WHERE (Q2.OrgID = Q1.OrgID)
ORDER BY Score DESC, EmpID
))
))
GROUP BY Q1.OrgID, Q1.OrgName
ORDER BY Sum(Q1.Score) DESC , Q1.OrgName;
I've turned the 'inner' SELECT in a saved query (qryQ2), but I'm having
trouble with the 'outer' query. Any clues? I'm guessing I don't know how to
write the IN(???).
much thanks
Becky