SQL Queries for Flight and Passenger Data
SQL Queries for Flight and Passenger Data
My query must display all the information of the passengers whose names contain the sequence
from the two letters 'MA', and having booked flight number 2. Express this query in SQL.
SELECT Passenger.*
FROM Passenger INNER JOIN Reservation ON [Link] = [Link]
Where [Link] like '*MA*' and [Link] = 2;
2/2
SELECT [Link], [Link], [Link]
FROM Pilot Inner Join Flight ON [Link] = [Link]
WHERE (Day([DateVol])=31 AND Month([DateVol]) IN (1,3) AND Year([DateVol]) IN
(2014,2015)) OR (Day([DateVol])=28 AND Month([DateVol])=2 AND Year([DateVol])
In (2014, 2015));
c. Display the flight number and the flight months of Boeing type airplanes, whose months are
displayed in letters and the number of places is not between 350 and 500.
d. Display the number, the name, the first name, and the reduced price of the passengers if we gave a
5% reduction on the flight price for first-class or business travelers and 0% in
the opposite case.
2/2
SELECT [Link], [Link], [Link]
IIf([FlightClass] In ("First", "Business"), [FlightPrice] * 0.95, [FlightPrice]) AS ReducedPrice
e. For each pilot, display the number, the name, and the total number of their flights during the
last quarter of a given year as a parameter.
f. Increase the ticket price by 10% for booked business class flights.
3 days before the flight date in the year 2016.
[Link] = "PrixVol*1,1"
WHERE [Link]='Business' AND DateDiff('d',[reservationDate],
[datevol])<=3 AND Year([DateReserv])=2016;
g. Display the average monthly flight prices for the last six months of
the current year, by flight class. The classes should be displayed in columns and the names
for months online.
2/2
TRANSFORM Avg(PriceVolume) AS AvgPriceVolume
SELECT Format([DateVol],"mmmm") AS MoisVol
FROM Flight INNER JOIN Reservation ON [Link] = [Link]
WHERE (((DateDiff("m",[DateVol],Date()))<=6))
GROUP BY Format([DateVol],"mmmm")
PIVOT [Link];
2/2