#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep 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.
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,244
    Rep Power
    4279
    Originally Posted by PIPC
    I've had the following question on a test...
    nice try

    we don't do homework assignments on this site unless you make a real good effort yourself first
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo