8 Southwest Airlines SQL Interview Questions (Updated 2024)

Updated on

June 30, 2024

Data Scientists, Analysts, Engineers at Southwest Airlines use SQL in their role on the daily. They use SQL for analyzing flight data to optimize operations and generating customer behavior insights for marketing strategies. That's why Southwest Airlines LOVES to ask folks interviewing at the company SQL coding interview questions.

To help you study for the Southwest Airlines SQL interview, we've curated 8 Southwest Airlines SQL interview questions – scroll down to start solving them!

Southwest Airlines SQL Interview Questions

8 Southwest Airlines SQL Interview Questions

SQL Question 1: Find VIP Customers from Southwest Airlines

Southwest Airlines wants to identify their VIP customers. In order to identify the power users, we are tasked to find the customers who have flown more than 100 times per year. Write a SQL query to find out these customers' ids and the total number of flights they took in the past year.

Given two tables, and , which have the following structure and sample data:

Example Input:
Example Input:
200110106/08/2021 00:00:00
200210106/10/2021 00:00:00
200310206/18/2021 00:00:00
200410306/18/2021 00:00:00
200510207/26/2021 00:00:00
200610207/05/2021 00:00:00
200710108/05/2021 00:00:00

Note: The flight dates are given in the format 'MM/DD/YYYY'.


The PostgreSQL query to solve this would be:

This query joins the customers and the flights tables on the customer_id field, then filters for flights that took place within the past year (using the BETWEEN clause). It then groups the results by customer_id and counts the number of flights for each customer (using the COUNT() function). The HAVING clause is used to filter groups (after the GROUP BY clause) that have more than 100 flights.

To practice a related customer analytics question on DataLemur's free online SQL code editor, try this recently asked Microsoft SQL interview question: Microsoft SQL Interview Question: Teams Super User

SQL Question 2: Department Salaries

Suppose you had a table of Southwest Airlines employee salary data, along with which department they were in. Write a query to compare the average salary of employees in each department to the company's average salary for March 2024. Return the comparison result as 'higher', 'lower', or 'same' for each department. Display the department ID, payment month (in MM-YYYY format), and the comparison.

Check out the SouthWest Airlines One Report for more context!

Try this problem and run your code right in DataLemur's online SQL environment:

Department vs. Company Salary

The answer is LONG – 30+ lines of SQL. You can find a detailed solution with hints here: Department Salaries.

SQL Question 3: What does adding 'DISTINCT' to a SQL query do?

The clause is used to remove all duplicate records from a query.

For example, if you had a table of open jobs Southwest Airlines was hiring for, and wanted to see what are all the unique job titles that were currently available at the company, you could write the following query:

Southwest Airlines SQL Interview Questions

SQL Question 4: Analyze Airline Delay Patterns

Southwest Airlines would like to understand how delays are distributed across their different departure cities. You have been given a dataset that contains information about each flight, including its departure city, arrival city, scheduled departure time, actual departure time, and delay time (in minutes). {#Question-4}

Please write a SQL query to identify the Top 5 departure cities with the highest average flight delay time in year 2021.

Below is the provided table:

Example Input:
315Los AngelesDenver2021-01-02 07:30:002021-01-02 08:00:0030
701New YorkLos Angeles2021-01-10 12:00:002021-01-10 12:45:0045
922ChicagoNew York2021-01-18 16:00:002021-01-18 16:00:000
503Los AngelesChicago2021-02-25 20:00:002021-02-25 20:45:0045
791New YorkSeattle2021-05-23 11:00:002021-05-23 13:00:00120
454ChicagoDallas2021-06-30 15:30:002021-06-30 15:45:0015


Here is the PostgreSQL query to get the top 5 departure cities with the highest average flight delay in 2021:

The query groups the data by departure city and calculates the average delay time for each city. It then orders these averages in descending order and limits the output to only the top 5 cities. Please note that this query will only include flights that were scheduled to depart in 2021.

Pro Tip: Window functions are a frequent SQL interview topic, so practice every window function problem on DataLemur

DataLemur SQL Questions

SQL Question 5: What's the difference between a unique and non-unique index?

Some similarities between unique and non-unique indexes include:

  1. Both types improve the performance of SQL queries by providing a faster way to lookup the desired data.
  2. Both types use an additional data structure to store the indexed data, which requires additional storage space which impacts write performance.
  3. Both types of indexes can be created on one or more columns of a table.

Some differences between unique and non-unique indexes include:

  1. A unique index enforces the uniqueness of the indexed columns, meaning that no duplicate values are allowed in the indexed columns. A non-unique index allows duplicate values in the indexed columns.
  2. A unique index can be used to enforce the primary key of a table, but a non-unique index cannot.
  3. A unique index can have a maximum of one NULL value in the indexed columns, but a non-unique index can have multiple NULLs

SQL Question 6: Filter Customer Flight History

Southwest Airlines would like to implement a new marketing strategy. For that, they are interested in analyzing their customer flight records based on specific conditions. They want to know the count of customers who have frequently traveled between Dallas and Houston in last quarter, and have also availed in-flight meals. A frequent traveler is defined as a customer who has made more than 4 trips in the last quarter.

Example Input:
106C003New YorkBoston03/15/2022No
108C003BostonNew York03/25/2022No


This query counts the number of customers who meet all the specified conditions:

  1. They traveled between Dallas and Houston (either way)
  2. Availed in-flight meal service
  3. Traveled within the last quarter
  4. Made more than 4 trips in that period.

It uses the , , and SQL clauses to filter and aggregate the data. It also makes use of clause to filter data on single or multiple conditions. The command is used to filter the data within a specific date range.

SQL Question 7: Can you explain the purpose of the SQL constraint?

A UNIQUE constraint ensures that all values in a column are different. It is often used in conjunction with other constraints, such as NOT NULL, to ensure that the data meets certain conditions.

For example, if you had Southwest Airlines employee data stored in a database, here's some constraints you'd use:

In the Southwest Airlines employee example, the UNIQUE constraint is applied to the "email" field to ensure that each employee has a unique email address. This helps to ensure the integrity of the data in the database and prevents errors that could occur if two employees had the same email address.

SQL Question 8: Average flight delay per route for Southwest Airlines

Find the average delay time per flight route for Southwest Airlines. Delay is defined as the difference between scheduled departure time and actual departure time. For the purpose of this problem, consider positive delays only (i.e., the flights that left later than scheduled).

We'll have a table, and each row corresponds to a single one-way flight.

Example Input:
110008/01/2022 10:00:0008/01/2022 10:35:00
220008/02/2022 15:30:0008/02/2022 15:50:00
310008/02/2022 10:00:0008/02/2022 10:30:00
430008/03/2022 12:00:0008/03/2022 12:00:00
520008/03/2022 15:30:0008/03/2022 15:55:00
Example Output:

Delay times were calculated as follows: For route 100, (35 + 30)/2 = 17.5 minutes. For route 200, (20 + 25)/2 = 12.5 minutes. Route 300 was not delayed, so it didn't show in the results.


The query should look something like this:

This SQL query first subtracts from to calculate delay for each flight. It only considers cases where is greater than (meaning these are delayed flights). The function then converts the time interval to seconds (as ), and we divide by 60 to get minutes. The function is applied to these delay times grouped by , to find the average delay per route. If there is no delay for any flight for a certain route, that route will not shop up in the output.

To practice a very similar question try this interactive Amazon Highest-Grossing Items Question which is similar for calculating average metrics or this Twitter Tweets' Rolling Averages Question which is similar for time-series averages.

Southwest Airlines SQL Interview Tips

The key to acing a Southwest Airlines SQL interview is to practice, practice, and then practice some more! In addition to solving the earlier Southwest Airlines SQL interview questions, you should also solve the 200+ FAANG SQL Questions on DataLemur which come from companies like Netflix, Google, and Amazon. DataLemur SQL Interview Questions

Each exercise has hints to guide you, step-by-step solutions and crucially, there is an online SQL code editor so you can right online code up your SQL query and have it checked.

To prep for the Southwest Airlines SQL interview you can also be wise to solve interview questions from other airlines like:

In case your SQL foundations are weak, don't worry about going right into solving questions – refresh your SQL knowledge with this free SQL for Data Analytics course.

DataLemur SQL tutorial

This tutorial covers SQL concepts such as filtering data with boolean operators and filtering data with WHERE – both of these show up routinely during SQL job interviews at Southwest Airlines.

Southwest Airlines Data Science Interview Tips

What Do Southwest Airlines Data Science Interviews Cover?

Besides SQL interview questions, the other topics to prepare for the Southwest Airlines Data Science Interview are:

  • Probability & Stats Questions
  • Coding Questions in Python or R
  • Open-Ended Data Case Studies
  • ML Modelling Questions
  • Behavioral & Resume-Based Questions

Southwest Airlines Data Scientist

How To Prepare for Southwest Airlines Data Science Interviews?

I'm sorta biased, but I think the optimal way to prep for Southwest Airlines Data Science interviews is to read the book I wrote: Ace the Data Science Interview.

The book has 201 data interview questions sourced from Microsoft, Amazon & startups. It also has a crash course covering SQL, Product-Sense & ML. And finally it's vouched for by the data community, which is why it's got over 1000+ 5-star reviews on Amazon.

Nick Singh author of the book Ace the Data Science Interview