Query_Solution

Query_Solution - FROM FLIGHTS FLIGHT_ATTENDANCE WHERE...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Solution Querying Assignment 1. List the crew members of the flight 123 on May 5, 2007 SELECT FLIGHT_ATTENDANCE.EID, FLIGHT_ATTENDANCE.FLNO, FLIGHT_ATTENDANCE.DAY FROM FLIGHT_ATTENDANCE WHERE (((FLIGHT_ATTENDANCE.FLNO)=123) AND ((FLIGHT_ATTENDANCE.DAY)= '5/5/2007')); Query1 EID FLNO DAY 1 123 5/5/2007 5 123 5/5/2007 2. List the flight attendants who flew to Chicago at list once since January 1 st 2007. SELECT FLIGHT_ATTENDANCE.EID FROM FLIGHT_ATTENDANCE WHERE (((FLIGHT_ATTENDANCE.DAY)>= '1/1/2007')) AND FLIGHT_ATTENDANCE.FLNO IN (SELECT FLIGHTS.FLNO FROM FLIGHTS WHERE FLIGHTS.DESTINATION ='Chicago'); Query2 EID DAY 4 2/3/2007 2 3/6/2007 3. Find the employees who flew only to Chicago. SELECT FLIGHT_ATTENDANCE.EID FROM FLIGHT_ATTENDANCE WHERE FLIGHT_ATTENDANCE.EID NOT IN (SELECT FLIGHT_ATTENDANCE.EID
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: FROM FLIGHTS, FLIGHT_ATTENDANCE WHERE FLIGHTS.FLNO= FLIGHT_ATTENDANCE.FLNO AND FLIGHTS.DESTINATION<>'Chicago'); Query3 EID 4 6 4. List the employees who have been to all the cities. SELECT DISTINCT FA.EID FROM FLIGHT_ATTENDANCE FA WHERE NOT EXISTS (SELECT * FROM FLIGHTS FL WHERE NOT EXISTS (SELECT * FROM FLights FL2, FLIGHT_ATTENDANCE FA2 WHERE FL2.DESTINATION=FL.DESTINATION and FA2.EID=FA.EID and FL2.FLNO=FA2.FLNO)) Query4 EID 2 5. List pairs of employees who worked together on at least one flight. SELECT FL1.EID, FL2.EID FROM FLIGHT_ATTENDANCE FL1, FLIGHT_ATTENDANCE FL2 WHERE FL1.FLNO=FL2.FLNO AND FL1.DAY=FL2.DAY AND FL1.EID<>FL2.EID; Query5 FL1.EID FL2.EID 5 1 6 3 1 5 3 6...
View Full Document

{[ snackBarMessage ]}

Page1 / 3

Query_Solution - FROM FLIGHTS FLIGHT_ATTENDANCE WHERE...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online