-
Notifications
You must be signed in to change notification settings - Fork 0
/
SQL QUERIES.txt
108 lines (72 loc) · 2.85 KB
/
SQL QUERIES.txt
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
108
1- TOTAL PROFIT, COST AND NUMBER OF TICKETS FOR JANUARY
SELECT SUM (extended_total_profit) profit,
SUM (FLIGHT_COST) tcost,
SUM (TOTAL_TICKETS) t_ticket_number
FROM total_flight_fact
WHERE date_key < 20210201
2- TOTAL SEATS UTILIZED FOR JANUARY
SELECT (SUM (tf.TOTAL_TICKETS) / SUM (ff.seats_number)) AS utlization
FROM total_flight_fact tf, flight_fact ff
WHERE tf.flight_key = ff.flight_key AND tf.date_key < 20210201
3- SHOWING ALL INQUIRIES WITH THEIR TIME, STATUS AND SEVERITY LEVEL
SELECT Pa.FIRST_NAME,
Pa.LAST_NAME,
Pa.MEMBERSHIP_STATUS,
S.STAFF_NAME,
S.ROLE,
I.INQUIRY_ID,
I.INTQUIRY_TIME,
I.INQUIRY_status,
I.SEVERITY
FROM REPORT_INQUIRY_fact
JOIN PASSANGER Pa USING (PASSENGER_KEY)
JOIN STAFF S USING (STAFF_KEY)
JOIN INQUIRIES I USING (INQUIRY_KEY)
4- NUMBER OF TICKETS BOOKED FROM AGENCIES
SELECT COUNT (passenger_Key)
FROM booking_fact
WHERE website_key IS NULL;
5- NUMBER OF PASSENGERS THAT HAVE DISCOUNT LARGER THAN 50$
SELECT COUNT (passenger_Key)
FROM booking_fact
WHERE promotional_discount > 50
6- NUMBER OF FREQUENT FLYERS IN EACH MEMBERSHIP STATUS
SELECT COUNT (FQ_Key), MEMBERSHIP_STATUS
FROM loyalty_fact
JOIN passanger USING (passenger_key)
JOIN frequent_flyer USING (fq_key)
GROUP BY MEMBERSHIP_STATUS
7- NUMBER OF INQUIRIES IN EACH PERIOD
SELECT I.INTQUIRY_TIME, COUNT (I.INQUIRY_ID)
FROM REPORT_INQUIRY_fact
JOIN PASSANGER Pa USING (PASSENGER_KEY)
JOIN INQUIRIES I USING (INQUIRY_KEY)
GROUP BY I.INTQUIRY_TIME
ORDER BY I.INTQUIRY_TIME
8- DURATION OF FREQUENT FLYERS AT THE HOTELS FOR JANUARY
SELECT FQ.FQ_ID,
H.HOTEL_NAME,
HS.RESERVATION_ID,
H.HOTEL_RATING,
ST.DURATION
FROM STAYING_FACT ST
JOIN FREQUENT_FLYER FQ USING (FQ_KEY)
JOIN HOTEL H USING (HOTEL_KEY)
JOIN HOTEL_STAYING HS USING (HOTEL_STAYING_KEY)
JOIN DATE_dim D USING (DATE_KEY)
WHERE TO_CHAR (D.DATE_d, 'MON') = 'JAN';
9- TOTAL DURATION SPENT BY EVERY FREQUENT FLYER
SELECT FQ.FQ_ID, SUM (ST.DURATION)
FROM STAYING_FACT ST
JOIN FREQUENT_FLYER FQ USING (FQ_KEY)
JOIN HOTEL_STAYING HS USING (HOTEL_STAYING_KEY)
GROUP BY FQ.FQ_ID;
10- HOTELS WITH HIGH DURATION FOR JANUARY
SELECT H.HOTEL_NAME, SUM (ST.DURATION)
FROM STAYING_FACT ST
JOIN FREQUENT_FLYER FQ USING (FQ_KEY)
JOIN HOTEL H USING (HOTEL_KEY)
JOIN HOTEL_STAYING HS USING (HOTEL_STAYING_KEY)
JOIN DATE_dim D USING (DATE_KEY)
WHERE TO_CHAR (D.DATE_d, 'MON') = 'JAN'
GROUP BY H.HOTEL_NAME