MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

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 Dev Shed Forums Sponsor:
  #1  
Old November 17th, 2012, 03:27 PM
PIPC PIPC is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 PIPC User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #2  
Old November 17th, 2012, 04:38 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 43rd Plane (26000 - 26499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 26,444 r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level)r937 User rank is General 47th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 14 h 25 m 12 sec
Reputation Power: 4141
Quote:
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Basic SQL question from a test

Developer Shed Advertisers and Affiliates



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

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


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap