SQL is used across Spirit AeroSystems Holdings for analyzing aircraft component performance data, and managing supply chain databases to optimize production efficiency. Because of this, Spirit AeroSystems almost always asks SQL coding questions during interviews for Data Science, Analytics, and & Data Engineering jobs.
So, if you're studying for a SQL Assessment, we've collected 11 Spirit AeroSystems Holdings SQL interview questions to practice, which are similar to recently asked questions at Spirit AeroSystems – can you solve them?
Spirit AeroSystems is a major supplier of aerostructures to globally recognized aviation brands. They maintain a track record of orders made by customers, with some customers ordering more frequently than others. For strategic business intelligence purposes, Spirit AeroSystems wants to identify 100 customers who have made the highest number of orders in the year 2022, who will be tagged as "Power Users". Assume that you have a table named with the following schema.
Write an SQL query to identify these power users.
order_id | customer_id | order_date | product_id | quantity |
---|---|---|---|---|
5001 | 125 | 03/08/2022 00:00:00 | 70001 | 10 |
6002 | 265 | 06/10/2022 00:00:00 | 80052 | 7 |
7003 | 362 | 02/18/2022 00:00:00 | 70001 | 5 |
8004 | 125 | 08/26/2022 00:00:00 | 80052 | 12 |
9005 | 984 | 01/05/2022 00:00:00 | 80052 | 2 |
This SQL query groups orders by and gets the count of orders made by each customer in the year 2022, and sorts them in descending order of order count to get the top 100 customers with the most orders. The highest number of orders made by a customer indicates that they are a power user.
To solve a super-customer analysis question on DataLemur's free interactive coding environment, try this Microsoft Azure Cloud SQL Interview Question:
As a data analyst for Spirit AeroSystems, you have been given a task to analyze the usage history of various aircraft parts. Each part has a unique and each part is used in an aircraft with a unique . The date of part usage is recorded in the field.
You are asked to provide a monthly report which should indicate the first usage of parts in each aircraft for every year-month. The analysis is confined to the year 2020 and the output should contain , , , and .
usage_id | aircraft_id | part_id | used_date |
---|---|---|---|
101 | AC001 | P001 | 2020-06-10 |
102 | AC001 | P001 | 2020-07-15 |
103 | AC001 | P002 | 2020-06-24 |
104 | AC002 | P001 | 2020-08-20 |
105 | AC002 | P003 | 2020-05-18 |
106 | AC001 | P002 | 2020-09-14 |
year_month | aircraft_id | part_id | first_used_date |
---|---|---|---|
2020-05 | AC002 | P003 | 2020-05-18 |
2020-06 | AC001 | P001 | 2020-06-10 |
2020-06 | AC001 | P002 | 2020-06-24 |
2020-08 | AC002 | P001 | 2020-08-20 |
2020-09 | AC001 | P002 | 2020-09-14 |
This query uses window function and to find out the first usage date of each part for each aircraft in each year-month. We filter the data for the year 2020 using the clause. Finally, we order the result by , and to clearly see the usage pattern.
To solve a similar window function interview problem which uses RANK() on DataLemur's free online SQL coding environment, try this Amazon SQL Interview Question:
A join in SQL combines rows from two or more tables based on a shared column or set of columns.
Four types of JOINs exist in SQL. To demonstrate each one, say you had a table of Spirit AeroSystems orders and Spirit AeroSystems customers.
INNER JOIN: When there is a match in the shared key or keys, rows from both tables are retrieved. In this example, an between the Orders and Customers tables would retrieve rows where the in the Orders table matches the in the Customers table.
LEFT JOIN: A retrieves all rows from the left table (in this case, the Orders table) and any matching rows from the right table (the Customers table). If there is no match in the right table, NULL values will be returned for the right table's columns.
RIGHT JOIN: A retrieves all rows from the right table (in this case, the Customers table) and any matching rows from the left table (the Orders table). If there is no match in the left table, NULL values will be returned for the left table's columns.
FULL OUTER JOIN: A retrieves all rows from both tables, regardless of whether there is a match in the shared key or keys. If there is no match, NULL values will be returned for the columns of the non-matching table.
One of the key challenges Spirit AeroSystems has is to track and maintain the various parts and assemblies for each aircraft. Spirit AeroSystems wants to list all the Aircrafts that have at least one part due for maintenance in the next 30 days.
Given tables and and that today's date is .:
aircraft_id | model | manufacturer | year_made |
---|---|---|---|
1 | A380 | Airbus | 2008 |
2 | B737 | Boeing | 1997 |
3 | A350 | Airbus | 2014 |
part_id | aircraft_id | manufacturer | manufacturing_date | next_maintenance_due |
---|---|---|---|---|
1 | 1 | Boeing | 2010-01-01 | 2022-10-01 |
2 | 1 | Boeing | 2012-02-01 | 2022-12-01 |
3 | 2 | Airbus | 2005-06-20 | 2022-08-15 |
4 | 3 | Boeing | 2016-03-30 | 2022-11-05 |
5 | 3 | Airbus | 2015-05-07 | 2022-09-01 |
A foreign key is a column or group of columns in a table that refers to the primary key in another table. The foreign key constraint helps maintain referential integrity between the two tables.
The table with the foreign key is called the child table, while the table with the candidate key is called the parent or referenced table.
For example, consider a database with two tables: and customer_idcustomer_idcustomer_id` column in Spirit AeroSystems customers table.
As a data analyst at Spirit AeroSystems, you are asked to calculate the average duration (in days) of projects in the last year. Here, is a table with each row representing a specific project that includes columns for , , , and . Calculate the average duration for each project category in the last year.
project_id | project_name | category | start_date | end_date |
---|---|---|---|---|
101 | Turbofan A | Engine | 2021-01-01 | 2021-04-30 |
102 | Turbofan B | Engine | 2021-02-15 | 2021-06-30 |
103 | Fuselage X | Fuselage | 2021-05-01 | 2021-10-31 |
104 | Wingset 1 | Wings | 2021-07-01 | 2022-01-15 |
105 | Fuselage Y | Fuselage | 2021-11-15 | 2022-03-15 |
category | avg_duration_days |
---|---|
Engine | 120 |
Fuselage | 165 |
Wings | 200 |
This query first filters the projects that have started in the last year. Then, function is used to calculate the number of days a project has taken by subtracting from . The average of these durations is then grouped by the of the project. The function in SQL is used to compute the average duration of the projects.
To practice a very similar question try this interactive Wayfair Y-on-Y Growth Rate Question which is similar for calculating rates over a time period.
The / operator is used to remove to return all rows from the first SELECT statement that are not returned by the second SELECT statement.
Note that is available in PostgreSQL and SQL Server, while MINUS is available in MySQL and Oracle (but don't stress about knowing which DBMS supports what exact commands since the interviewers at Spirit AeroSystems should be lenient!).
Here's a PostgreSQL example of using EXCEPT to find all of Spirit AeroSystems's Facebook video ads with more than 10k views that aren't also being run on YouTube:
If you want to retain duplicates, you can use the EXCEPT ALL operator instead of EXCEPT. The EXCEPT ALL operator will return all rows, including duplicates.
Suppose you're a database analyst at Spirit AeroSystems. Your job is to analyze the sales data of various aircraft parts. The company offers many different aircraft models with different parts.
Your task is to write a SQL query that provides a summary of which aircraft part model has generated the most total revenue (the revenue for a part is calculated by multiplying the part price by qty), for each month.
Using Spirit AeroSystems parts sales database, here's how a sample table looks like:
sale_id | sale_date | part_id | part_price | qty |
---|---|---|---|---|
1001 | 06/05/2022 | 321 | 5000 | 2 |
1002 | 06/25/2022 | 435 | 12000 | 3 |
1003 | 06/28/2022 | 321 | 5000 | 4 |
1004 | 07/10/2022 | 435 | 12000 | 1 |
1005 | 07/11/2022 | 648 | 10000 | 5 |
This query will return a table with the month, the part_id, and the maximum revenue earned from the sale of that part in the given month. Ensure your date column is a date or a datetime datatype to use the EXTRACT() function. If it's a string, first convert it to a date.
The answer should be in the format:
month | part_id | max_revenue |
---|---|---|
6 | 321 | 20000 |
6 | 435 | 36000 |
7 | 435 | 12000 |
7 | 648 | 50000 |
Spirit AeroSystems is interested in identifying customers located in Wichita. They have a large customer base and want to focus more on local customer relationships. There is a customers table with each customer's id, name, and location. You are tasked to find all customers who are located in Wichita.
Please write an SQL query to filter the records in the customer table where the location field matches the string 'Wichita'.
customer_id | name | location |
---|---|---|
100 | Ashley Johnson | Wichita |
101 | Jacob Sample | Seattle |
102 | Emily Rose | Wichita |
103 | Michael Scott | New York |
104 | Mary Williams | Wichita |
customer_id | name | location |
---|---|---|
100 | Ashley Johnson | Wichita |
102 | Emily Rose | Wichita |
104 | Mary Williams | Wichita |
This SQL query searches for the string 'Wichita' in the location column of the customers table. This helps to identify local customers, which can be used for targeted marketing or customer relationship initiatives.
Database normalization is helpful because it improves the performance, flexibility, and scalability of a database. Some specific benefits of normalization include:
Reducing Redundancy: Normalization helps to minimize redundancy by breaking down a larger general table into smaller, more specific tables. This can often reduce the amount of data that needs to be accessed for particular queries.
Improving Data Integrity: Normalization helps to ensure the integrity of the data by minimizing the risk of data inconsistencies and anomalies. It does this by establishing clear relationships between the tables via primary and foreign keys.
Increasing Flexibility: Normalization makes it easier to modify the structure of the database, as there is less redundancy, so it allows you to make changes to one table without affecting others. This makes it easier to adapt the database to changing business needs (and change is basically constant at Spirit AeroSystems!)
Improving Performance: Normalization can improve the performance of the database by reducing the amount of data that needs to be stored and accessed in a single table. This can result in faster query times and better overall performance.
Easier Data Modeling: Normalization can make it easier to model the data in a logical and intuitive way, since less random data is commingled together, which improves the overall database design.
As an analyst for Spirit AeroSystems, you have been tasked with tracking the cost of materials per aircraft model. You need to calculate the average cost of materials used per aircraft model, rounded to the nearest whole number. You also want to understand the variation in cost, so you calculate the absolute difference between the highest and lowest material cost per model. For ease of comparison, you want to normalize these absolute differences by finding their square root.
Let's assume the following tables:
aircraft_id | model |
---|---|
1 | 'Model A' |
2 | 'Model B' |
3 | 'Model C' |
4 | 'Model D' |
material_id | aircraft_id | cost ($) |
---|---|---|
101 | 1 | 500 |
102 | 1 | 600 |
103 | 2 | 400 |
104 | 2 | 700 |
105 | 3 | 800 |
106 | 4 | 650 |
The SQL query could be written as follows:
This query first joins the two tables on their common field. It then groups the results by aircraft model, calculating the average material cost, and the square root of the absolute difference between the maximum and minimum material cost, per model. This gives us a sense of the average cost and variation of cost for each aircraft model.
To practice a very similar question try this interactive Tesla Unfinished Parts Question which is similar for dealing with data on individual parts.
Assuming that you've already got basic SQL skills, the next best tip we have to prepare for the Spirit AeroSystems SQL interview is to solve as many practice SQL interview questions as you can!
Besides solving the above Spirit AeroSystems SQL interview questions, you should also solve the 200+ DataLemur SQL Interview Questions which come from companies like Google, Facebook, Microsoft and Amazon.
Each interview question has hints to guide you, fully explained answers along with a discussion board to see how others solved it and most importantly, there's an online SQL code editor so you can instantly run your query and have it executed.
To prep for the Spirit AeroSystems SQL interview you can also be helpful to practice interview questions from other defense & aerospace contractors like:
In case your SQL query skills are weak, don't worry about going right into solving questions – go learn SQL with this SQL interview tutorial.
This tutorial covers things like WHERE with AND/OR/NOT and aggregate functions like SUM()/COUNT()/AVG() – both of which show up frequently in Spirit AeroSystems interviews.
For the Spirit AeroSystems Data Science Interview, beyond writing SQL queries, the other types of questions to prepare for are:
To prepare for Spirit AeroSystems Data Science interviews read the book Ace the Data Science Interview because it's got: