SQL Practice Questions

Similar documents
CISC 7510X Midterm Exam For the below questions, use the following schema definition.

2. (5 points) Who was John Doe s driver on April 1st, 2018?

COP 4540 Database Management

SWEN502 Foundations of Databases Session 2. Victoria University of Wellington, 2017, Term 2 Markus Luczak-Roesch

Solutions to Examination in Databases (TDA357/DIT620)

FINAL EXAM: DATABASES ("DATABASES") 22/06/2010 SCHEMA

CSCE 520 Final Exam Thursday December 14, 2017

JFK LHR. airports & flight connections

ELOQUA INTEGRATION GUIDE

Part 1. Part 2. airports100.csv contains a list of 100 US airports.

Operations Manual. FS Airlines Client User Guide Supplement A. Flight Operations Department

Best Airlines AIRNAME AIRNAME. MECHANIC table MECHNAM E TELEPHON E MECHNUM MECHNUM SALARY. AIRPORT table YEAROPEN ED. SKILL table. QUALIFICATION table

EASTERN MILES MEMBERSHIP TERMS AND CONDITIONS

Handling Transfers in Travel Booster

Airline Monthly Point to Point Guidance Notes

Steep increases in overnight stays and revenue

Booking flights At the restaurant Wiki. Triggers. February 24, Grégoire Détrez Tutorial 4

Query formalisms for relational model relational algebra

10 - Relational Data and Joins

CONTACT ON (888) FOR ANY QUERY RELATED TO BOOKING AMERICAN AIRLINES RESERVATIONS

Short-Haul Operations Route Support Scheme (RSS)

Portability: D-cide supports Dynamic Data Exchange (DDE). The results can be exported to Excel for further manipulation or graphing.

MU-avtalet. In English

Page 1 sur 19 LFTH

Physical Security Fleets Analyzer Saved Searches... 62

Asynchronous Query Execution

Residents ensure increase on overnight stays in hotels and similar establishments

Introduction to Data Management CSE 344

The Improvement of Airline Tickets Selling Process

DATABASE DESIGN FOR HOTE DU AUSTRIA: PROBLEM & SOLN.

Management System for Flight Information

Easter boosts results in tourism accommodation

PRESS RELEASE SURVEY ON QUALITATIVE CHARACTERISTICS OF RESIDENT TOURISTS: 2016 (provisional data)

European Virtual Airlines

Travel and epay User Group Meeting

Derivation of xuml Models

GATWICK NIGHT MOVEMENT AND QUOTA ALLOCATION PROCEDURES

Monday 22 May 2017 Afternoon

Project 2 Database Design and ETL

SERVICE LETTER COMMUNICATIONS - LINK CPDLC AND VHF ACARS CONFIGURATION VERIFICATION

Participant Information

Easter boosts results in tourism accommodation

WALK-IN-INTERVIEW AIR INDIA-EXPERIENCED CABIN CREW

Significant increases in overnight stays and revenue

Knowledge Creation through User-Guided Data Mining: A Database Case

HEATHROW NIGHT MOVEMENT AND QUOTA ALLOCATION PROCEDURES Version 3

SUB:CSWIP3.1/3.2.2/PAINTING INSPECTION COURSES &EXAM DETAILS

GATWICK NIGHT MOVEMENT AND QUOTA ALLOCATION PROCEDURES

2018 Cathay Pacific Virtual 2 P a g e

AirFrance KLM - FlightPrice

Robert H. Lane, MBA, Ph.D. Lane Services, LLC Richard Gaines, PMP Salesian Missions

THIS IS A NEW SPECIFICATION

Project 2 Database Design and ETL

ANNEX C. Maximum Aircraft Movement Data and the Calculation of Risk and PSZs: Cork Airport

1) Complete the Queuing Diagram by filling in the sequence of departing flights. The grey cells represent the departure slot (10 pts)

SURVEY OF U3A MEMBERS (PART 1)

Management System for Flight Information

HCSS Travel Guidelines

Frequently asked questions (FAQ)

Tuesday 9 June 2015 Morning

Airfield Capacity Prof. Amedeo Odoni

Heathrow Airport Ltd Rail Engineering Access Statement Sunday 10 th December 2017 to Saturday 8 th December 2018

CONTEXTUAL ALIGNMENT OF ONTOLOGIES FOR SEMANTIC INTEROPERABILITY

EVERYTHING YOU NEED TO KNOW ABOUT BOOKING WITH A2BTRANSFERS.COM

Course Project. 1. Let staff make entries when a passenger makes reservations on a flight.

Concept, Method, Challenges. Jürgen Weiß. MA in Tourism Economics (University of applied Sciences Vienna)

Airfield Geometric Design Prof. Amedeo Odoni

Global formulas. Page1. Video filmed with GeneXus X Evolution 2

2nd forum. Airport FRA. procedure

Growth in hotel activity supported by the external market

Rami El Mawas CE 291

SAMPLE. If your competent authority requires you to hand in a signed paper copy of the report, please use the space below for signature:

Published by the Stationery Office, Dublin, Ireland. Government Publications Sales Office, Sun Alliance House, Molesworth Street, Dublin 2,

Intellectual Property and Sustainable Development: Documentation and Registration of Traditional Knowledge and Traditional Cultural Expressions

Part 406. Certification Procedures. (Effective December 29, 1960

Guyana Civil Aviation Authority. ATR Form M Instructions

The regional value of tourism in the UK: 2013

Airfield Geometric Design Prof. Amedeo Odoni

Preliminary results for 2017 point to increases of 8.9% in guests and 7.4% in overnight stays

Analysis of rainless periods within the DriDanube project

Heathrow Airport Property Rents 2016/17 Consultation Document

UVACARS User Guide Version 1.0

DEPARTMENT OF MANITOBA INFRASTRUCTURE

Non residents boost hotel activity

e-crew Horizon Air Trip Trades Notes for the Flight Attendants

UNITED NATIONS ECONOMIC AND SOCIAL COMMISSION FOR ASIA AND THE PACIFIC (ESCAP)

Experience with Digital NOTAM

EVENT SCHEDULE:* For more information visit

Travel (1) Working Sessions Hosting and Hospitality (3) Professional Development (2) Other Travel. Total Travel

Airline Scheduling Optimization ( Chapter 7 I)

FlightMaps Online Help Guide FAQ V1.2

Additional Boarding Setup and Daily Operations Guide

INFORMATION NOTE FOR PARTICIPANTS

GREETING A VISITOR (3) Organizing a trip (04) What activity would you organize to greet a foreign colleague in your country?

Friday 19 June 2015 Morning

Case No IV/M DELTA AIR LINES / PAN AM. REGULATION (EEC) No 4064/89 MERGER PROCEDURE. Article 6(1)(b) NON-OPPOSITION Date:

Main indicators kept growing

Estimating Domestic U.S. Airline Cost of Delay based on European Model

ECONOMIC AND SOCIAL COMMISSION FOR ASIA AND THE PACIFIC STATISTICAL INSTITUTE FOR ASIA AND THE PACIFIC

Overnights of residents and non residents increased by 9%, accelerating when compared with the previous month

Transcription:

SQL Practice Questions Consider the following schema definitions: Branch (branchno, street, city, postcode) Staff (staffno, fname,lname, position, sex, DOB, salary, branchno) PropertyforRent (propertyno, street, city, postcode, type, rooms, rent, ownerno, staffno, branchno) Client (clientno, fname, lname, telno, preftype, maxrent) PrivateOwner (ownerno, fname, lname, address, telno) Viewing (clientno, propertyno, viewdate, comment) Registration (clientno, branchno, staffno, datejoined) An instance of the above schemas is given in the last page of the examination. (You may detach and use it if necessary) For each case below, fill in the blanks such that the SQL queries correspond to the English language queries stated. Each blank is worth 2 points. 1. List the address of all branch offices in London or Bristol. SELECT * FROM branch WHERE city= London _OR city= bristol 2. List the staff with a salary between $10000 and $30000. SELECT staff_no WHERE salary between 10000 AND 30000

3. List the staff in descending order of salary. SELECT staff_no, salary ORDER BY salary DESC 4. Find the number of different properties viewed in April 2004. SELECT count (distinct propert_no) FROM Viewing WHERE viewdate BETWEEN 1-Apr-04 AND 30-Apr-04 5. Find the minimum, maximum and average staff salary. SELECT _min(salary), _max(salary)_, _avg(salary) 6. For each branch office with more than one member of staff, find the number of staff working in each branch and the sum of their salaries. SELECT branchno, _count(staffno)_, sum(salary) GROUP BY branchno HAVING count(staffno) >1 2

7. List the staff who work in the branch whose stree adress is 163 Main Street SELECT staffno, fname, lname, WHERE _branchno = (SELECT branchno FROM _branch WHERE _street= 163 Main str _) 8. Find all staff whose salary is larger than the salary of every staff member at branch with branchno B003. SELECT staffno, fname, lname, position, salary WHERE _salary > ALL (SELECT salary FROM staff WHERE brancno= B003 ) 9. For each branch, list the numbers and names of staff who manage properties, including the city in which the branch is located and the properties that the staff manage. SELECT b.branchno, b.city, s.staffno, fname, lname, properyno FROM Branch AS b, Staff AS s, _propertyforrent p WHERE b.branchno = s.branchno AND _s.staffno=p.staffno 10. List the clients who have viewed a property. SELECT clientno, fname, lname, propertyno, viewdate FROM client natural innerjoin viewing 3

11. Find the list of all cities where there is both a branch office and a property (SELECT city FROM Branch) INTERSECT (SELECT city FROM _PropertyforRent ) 12. Give all managers 5% increase to their salary UPDATE staff SET salary=salary*1.05 WHERE position= Manager 13. Delete all viewings that belong to property with property number PG4. DELETE FROM viewing WHERE _propertyno= P64 4

A- Consider the following relation schema for an airline database. customer(id, name, age, gender) onflight(id, flightno, flightdate) flightinfo(flightno, fromcity, tocity, starttime, duration) Assume all flights take place every day. Fill in the missing slots in each ofd the queries below. Each slot is worth 2 pts, except the first one, which is worth 1 pt. 1. Names of all customers above the age of 10 SELECT name FROM customer WHERE age>10 2. Flights (flightno, flightdate) on which there are at least two customers SELECT f1.flightno, f1.flightdate FROM onflight as f1, onflight as f2 WHERE f1.flightno = f2.flightno AND f1.flightdate=f2.flightdate AND f1.id <> f2.id 3. Flights (flightno, flightdate) on which there are at least two customers, as well as the number of passengers on the flights SELECT flightno, flightdate, count(id) as howmany FROM onflight GROUP BY flightno, flightdate HAVING howmany>1 5

4. Names of passengers who flew on flight TK102 at least once SELECT name FROM customer, onflight WHERE customer.id=onflight.id AND onflight.flightno= TK102 5. Names of customers who never flew on any flight SELECT name FROM customer left outer join flight WHERE flightno = NULL 6. Names of customers who flew on the same flight as Mr. Joe WITH joeflight(flightno) AS SELECT flightno FROM customer natural inner join onflight WHERE name = Joe SELECT name FROM customer, onflight, joeflight WHERE customer.id = onflight.id AND onflight.flightno = joeflight.flightno 6

7. The number of passengers on flight TK101 on 1/2/1999 SELECT count(id ) FROM onflight WHERE flightno= TK101 AND flightdate= 1/2/1999 8. The most popular destination (i.e. the city which received the most number of travellers) WITH city_tourists(tocity,howmany) AS SELECT tocity, count(*) FROM onflight natural inner join flightinfo GROUP BY tocity WITH mosttourist(howmany) AS SELECT max(howmany) FROM city_tourists SELECT tocity FROM city_tourists, mosttourist WHERE city_tourists.howmany = mosttourist.howmany 9. How many passengers ever flew to Istanbul? If somebody travelled to Istanbul more than one time, only one of those visits should be counted. SELECT count (distinct id) FROM onflight natural inner join flightinfo WHERE to_city = Istanbul 7

8