Ctr

Speedy Check-In

You're an analyst working for a US airline called "You Knighted Airlines". The airline has an online check-in process, but it only works for people who have uploaded their passport, and if their uploaded passport hasn't expired before the time of their flight. In order to save more time at the check-in counter, the airline wants to promote this feature. The marketing team wants to send emails to users reminding them to upload up-to-date passports to enable speedy check-in.

The passengers are in the passengers table, and their passports are in passports.


passengers
column_name type
id
INTEGER
name
VARCHAR
email
VARCHAR
phone_no
VARCHAR
mileage_number
VARCHAR
registered_at
TIMESTAMPTZ

passports
column_name type reference
id
INTEGER
NULL
user_id
INTEGER
passengers.id
name
VARCHAR
NULL
number
VARCHAR
NULL
country
VARCHAR
NULL
date_of_birth
DATE
NULL
expires_at
DATE
NULL

We will be sending emails to users if they haven't uploaded any passport. Furthermore, we also want to send an email if a user has a passport that will expire before any flights they've booked!

The passengers' flight info is in the flights table.


flights
column_name type reference
id
INTEGER
NULL
passenger_id
INTEGER
passengers.id
origin
VARCHAR
NULL
destination
VARCHAR
NULL
takeoff_time
TIMESTAMPTZ
NULL
conf_no
VARCHAR
NULL
flight_no
VARCHAR
NULL

Select the name and email for all passengers that meet the following criteria:

  1. Have at least 1 flight booked, and…
  2. Either haven't uploaded a passport, or their passport will expire before 1 of their booked flights departs.

Some users have multiple flights booked in the future. This may cause the same passenger to appear in the result more than once. We asked the marketing team if this is okay, and they say it is because they plan to send a user 1 email per flight.

DATE and TIMESTAMPTZ can be compared with the same operators as numbers.

© 2022 Andrew Carlson. All rights reserved.

name
VARCHAR
email
VARCHAR
1
Devyn Macejkovic
Devyn11@hotmail.com
2
Adrianna Gutkowski
Adrianna.Gutkowski@hotmail.com
3
Ursula Connelly
Ursula_Connelly62@yahoo.com
4
Mayra Robel
Mayra62@gmail.com
5
Luciano Beer
Luciano.Beer@yahoo.com
6
Elroy Sawayn
Elroy55@hotmail.com
7
Cordie Funk
Cordie.Funk@yahoo.com
8
Cory Franecki
Cory.Franecki@gmail.com
9
Adelia Olson
Adelia92@gmail.com
10
Guy Daniel
Guy_Daniel@hotmail.com
11
Johnnie Hammes
Johnnie88@gmail.com
12
Crawford Schultz
Crawford_Schultz45@yahoo.com
13
Bertrand Batz
Bertrand.Batz62@yahoo.com
14
Rowena Durgan
Rowena.Durgan80@yahoo.com
15
Zackery Stroman
Zackery.Stroman6@gmail.com
16
Marcus Lockman
Marcus3@hotmail.com
17
Carmelo Stark
Carmelo.Stark93@hotmail.com
18
Jesse Steuber
Jesse.Steuber17@gmail.com
19
Johann Stroman
Johann87@hotmail.com
19 rows

You haven't solved this challenge yet!
Are you sure you want to reveal the answer?