SQL TEST - Holiday Bookings
SQL TEST - Holiday Bookings
Sample Data:
Client table:
ClientNo Cname Address Town Postcode
1234 BILL SMITH 1 HIGH ST SWINDON SN3 1ER
1445 AMY WINEY 2 THE WAY BRISTOL BR14 1TY
1996 JO BROWN 6 MAY RD SWINDON SN4 5RP
Holiday table:
Hcode Destination Hotelno Startdate Duration Adultprice ChildPrice
TH056 ALICANTE H0011 10-MAY-08 14 1200 1000
CO529 MADRID H0222 21-MAY-07 7 1650 1400
SU112 RIMINI H0555 4-JUN-08 14 1500 1000
BY522 ALICANTE H1922 10-DEC-07 10 670 350
*Duration is shown in days
Hotel table:
Hotelno Name StarRating
H0011 EXCELSIOR 3
H0222 CONTINENTAL 5
H0555 SEA VIEW 4
Booking table:
Hcode Clientno Bookdate Adults Children Deposit
TH056 1234 1-SEP-08 2 2 200.00
TH056 1445 2-FEB-08 2 150.00
SU112 1996 10-JAN-08 1 1 300.00
CO529 1234 1-MAR-07 3 2 400.00
*adult = no of adults booked on the holiday children = no of children booked on the holiday
deposit = the deposit paid on the holiday by the client.
BOOKING CLIENT
Hcode* Clientno
Clientno*
HOLIDAY HOTEL
Hcode Hotelno
Hotelno*
STUDENT NO: …………………………………………………………..
1. List full details of clients living in Swindon. Order the list by clientno. (5)
2. List the client no and holiday code of clients who booked a holiday on 21st
May 2007. Display the clientno column heading as “Client Number” (5)
4. List the hotel name for the holiday with the code TH056 (5)
STUDENT NO: …………………………………………………………..
5. List the holiday code and the total number of bookings for each holiday.
Order the list by the total number of bookings, starting with the highest
number. (6)
6. List the holiday codes and destinations of all holidays that are due to start
within 90 days of today’s date. (5)
7. List the maximum adult price of 14 day holidays at each destination. (6)
8. List the names of clients who have booked a holiday Madrid, Alicante or
Rimini (7)
STUDENT NO: …………………………………………………………..
9. List the client name and holiday code for bookings with no children. (6)
10. Display the name and full address of clients who have booked a holiday in
September of any year (ie the booking date was in September). Display the
address as a single column containing the address, town and postcode fields
separated by commas, headed “Full address”. (7)
11. List the total number of hotels in each star rating, excluding any star ratings
with less than 10 hotels. (6)
STUDENT NO: …………………………………………………………..
12. Produce a query which will allow the user to input a holiday destination and
a holiday startdate and to retrieve full details of the holidays for the
destination and startdate entered. (6)
13. List the client numbers of customers who have booked any of the holidays
booked by clientno ‘1234’ (6)
14. The holiday code is coded such that the first and second digits of the code
represent the tour operator for the holiday. The three main operators are
coded as follows.
TH = Thompsons
CO = Cosmos
SU = Sunbreak
Write query which will list the total number of holidays offered by each of
the three main operators, showing the full name of the operator and the total
number of holidays for each. (8)
STUDENT NO: …………………………………………………………..
15. Produce a sales report which shows the total number of bookings and the
total income from those bookings less deposits paid, for each month in 2007.
(8)
16. For each destination, show the number of bookings made for that
destination, and also what percentage of total bookings this represents. (Note
the percentage is found by dividing the destination’s bookings by the number
of bookings for the whole of the company, then multiplying this by 100). As a
check, include a final row which shows the total number of bookings for the
whole company. (10)