-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathQuerys.sql
107 lines (88 loc) · 2.89 KB
/
Querys.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*First Query*/
select * from Passenger p , Ticket t
Where p.ticket_no = t.t_no and
t.price > 2000
/*Second Query*/
select COUNT(*) Number_Of_Flights , flight_no
from Flight
where YEAR(departure_date)='2020'
GROUP BY flight_no
/*Third Query*/
select fares_type , fname as First_Name , lname as Last_Name , b_date
from Fare inner join Ticket on Fare.ticket_no = Ticket.t_no
inner join Passenger on Ticket.t_no = Passenger.ticket_no
where YEAR(b_date) >= 2000;
/*Forth Query*/
SELECT r_no , destination , class , Flight.flight_no
from Route inner join Airplane on Route.plane_code = Airplane.plane_code
inner join Plane_flight_port on Airplane.plane_code = Plane_flight_port.plane_code
inner join Flight on Plane_flight_port.flight_no = Flight.flight_no
Where Flight.class = 'A'
ORDER BY Flight.flight_no
/*Fifth Query*/
Select COUNT(Flight.flight_no) Number_of_FLights , flight_no
from Flight
WHERE Flight.too = 'BOM'
Group by flight_no
/*6th Query*/
select CONCAT(fname ,' ', lname) as Passenger_Name
from Passenger inner join Ticket on Passenger.ticket_no = Ticket.t_no
inner join Flight on Ticket.flight_no = Flight.flight_no
where Flight.too = 'FRA'
Order by Passenger_Name
/*7th Query*/
Select COUNT(*) as NumberOfFLights , flight_no
from Flight
where MONTH(Flight.arrival_date) = '04'
group by flight_no
/*8th Query*/
Select Airline.airline_code , Airline.name , Flight.flight_no
from Airline inner join Airplane ON Airline.airline_code = Airplane.airline_code
inner join Plane_flight_port on Airplane.plane_code = Plane_flight_port.plane_code
inner join Flight on Plane_flight_port.flight_no = Flight.flight_no
where DAY(Flight.departure_date) = '02'
/*9th Query*/
Select *
from Passenger
where fname like 'a%'
/*10th Query*/
Select Ticket.t_type , CONCAT(fname , ' ' , lname) as Full_Name
from Ticket inner join Passenger on Ticket.t_no = Passenger.ticket_no
where Passenger.sex = 'M'
/*11th Query*/
Select CONCAT(fname, ' ' ,lname) as Passenger_Name
from Passenger
where Passenger.ticket_no NOT IN(
Select Ticket.t_no
from Ticket inner join Passenger on Ticket.t_no = Passenger.ticket_no
where Ticket.credit='N'
)
/*12th Query*/
select Distinct CONCAT(p.fname , ' ' ,p.lname) as Full_Name , p.ticket_no
from Passenger p
where p.ticket_no IN ( select f.ticket_no from Fare f)
/*13th Query*/
Select *
from Ticket
Where Ticket.price=(
Select MAX(Ticket.price)
from Ticket
)
/*14th Query*/
Select *
FROM Passenger
WHERE ticket_no IN(
SELECT Ticket.t_no FROM Ticket
GROUP BY Ticket.t_no
HAVING SUM(Ticket.price) >3500)
/*15th Query*/
SELECT CONCAT(fname , ' ' ,lname) as full_name
from Passenger inner join Ticket on Ticket.t_no = Passenger.ticket_no
where fname like '%a%' and lname like '%m%' and sex like 'F'
/*16th Query*/
select *
from ticket full outer join fare
on Ticket.t_no=fare.ticket_no
where Ticket.t_no in
(select Ticket.t_no from passenger inner join ticket on Passenger.ticket_no = Ticket.t_no
where Passenger.sex='F')