Beruflich Dokumente
Kultur Dokumente
CYCLE SHEET-II
BY
16MIS0318 - Y.V.B.MANIKANTA
SLOT: L21+L22
3)List the airport names which are arrival ports for atleast 3 flights.
SQL> SQL> select count(*) from airport a join leg_instance l on
a.airport_code=l.arrival_airport_code group by name having count(*)>=3;
4)Retrieve airport code that is greater than all airplane id of given airplane
type.
SQL> select a.airport_code from airport a,airplane a1 where
length(a.airport_code)>length(a1.airplane_id) and
a1.airplane_type=’&airplane_type’;
Output:- no rows selected
5)List the flight number that has no booking
SQL (select f.flight_number from flight f) minus (select s.flight_number from
seat_reservation s);
7)Retrieve the airport code that are only arrival and not departure port.
SQL> select a.airport_code from airport a ,flight_leg f where
a.airport_code=f.arrival_airport_code and a.airport_code not in (select
departure_airport_code from flight_leg) and a.airport_code in(select
arrival_airport_code from flight_leg);
Output:- no rows selected
8)Retrieve the flight numbers that arrive in all the cities of Tamilnadu.
SQL> select f.flight_number from flight_legf,airport a where
a.airport_code=f.arrival_airport_code and a.state=’Tamil Nadu’;
Or
SQL> select f.flight_number from flight_leg f join airport a on
a.airport_code=f.arrival_airport_code and a.state='Tamil Nadu'; OUTPUT:- NO
ROWS SELECTED.
9)Retrieve the country which has more than 10 airports
SQL> select country from airport group by country having count(*)>=10;
10. Find the airline which has highest number of intermediate stoppings
SQL>select airline from flight where flight_numberin(select flight_number
from flight_leg group by flight_number having count(*)=(select
max(count(leg_number)) from flight_leg group by flight_number));
11. List the flight number, the departure airport for the first leg of the
flight, and the arrival airport for the last leg of the flight.
SQL> select flight_number,departure_airport_code,arrival_airport_code from
flight_leg where departure_airport_code=(select min(departure_airport_code)
from flight_leg)
(or)
SQL>select flight_number,departure_airport_code,arrival_airport_code from
leg_instance where leg_number in(select min(leg_number)from leg_instance) or
leg_number in(select max(leg_number)from leg_instance);
Output:- FLIGHT_NUM DEPARTURE_AIRPORT_CODE
ARRIVAL_AIRPORT_CODE
108 MAA HYD
127 PNQ AUH
142 ORD DOH
18115 DEL BLR
3710 PNQ DEL
511 BLR MAA
6 rows selected.
12. List the flight numbers and weekdays of all flights or flight legs that
depart from Pune Airport (airport code ‘PNQ’) and arrive in Los Angeles
International Airport (airport code ‘LAX’).
SQL> select f.flight_number,f.weekdays from flight f,flight_legfl where
f.flight_number=fl.flight_number and departure_airport_code='PNQ' and
arrival_airport_code='LAX';
Output:- no rows selected
13. List the flight number, departure airport code, scheduled departure
time,arrival airport code, scheduled arrival time, and weekdays of all
flights or flight legs that depart from some airport in the city of Karnataka
and arrive at some airport in the city of Kerala.
SQL>
selectfl.flight_number,fl.scheduled_departure_time,fl.departure_airport_code
,fl.arrival_airport_code,fl.scheduled_arrival_time,f.weekdays,a.city from airport
a,flightf,flight_legfl where a.airport_code=fl.arrival_airport_code and
fl.flight_number=f.flight_number and a.city in('Karnataka','Kerla');
Output:- no rows selected
14. List all fare information for flight number ‘63072’.
SQL> select * from fare where flight_number=’63027’;
15. Retrieve the number of available seats for flight number ‘60372’//Flight
details not available in database choosing flight number “60372” and travel
date “30-nov-16”.
SQL> select leg_number,number_of_available_seats from leg_instance where
flight_number=’60372’ and travel_date='30-NOV-16';
MISCELLANEOUS
1).Create an empty table my flight with same structure as flight table.
SQL> create table my flight as (select * from flight where 0=1);