
November 17th, 2012, 03:27 PM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 2
Time spent in forums: 5 m 45 sec
Reputation Power: 0
|
|
|
Basic SQL question from a test
I've had the following question on a test and i don't think i can solve it correctly so I'm hoping you would help
A store has a few employees and a few managers. Every employee has a personal password and every manager has an experience rank. At every shift at the store there are employees and managers and every shift occurs at a certain time and date. Every manager and employee must partake in at least one shift. Every employee has one manager. A manager can write a report on every one of his employees. Every shift has a shift manager from the people that take the shift (either an employee or a manger).
1. What does the following query do?
SELECT workerId, COUNT(DISTINCT managerId) AS Recommandations FROM Report
WHERE context LIKE '%employee of the month%' AND managerId IN (SELECT id FROM
Manager WHERE experience >= 5)
GROUP BY workerId;
2. Write that query without using the IN operator
3. Write an SQL query that returns the names of all the employees who have worked at least 3 times with managers who wrote some reports.
|