At Textron, SQL is used often for analzying manufacturing data, and for storing data in supply chain databases. Unsurprisingly this is why Textron often tests SQL questions in interviews for Data Science and Data Engineering positions.
So, if you're trying to prepare for the SQL Assessment, here’s 8 Textron SQL interview questions to practice – how many can you solve?
Textron relies heavily on their big customers, who frequently buy their products. These are referred to as 'whale users' within the company. Your task is to identify these whale users from the customer database. Specifically, create a SQL query that returns the user_id, total spending, and total quantity of purchases made by these customers within the past 12 months, sorted in descending order of total spending.
Assume we have the following tables:
product_id | price |
---|---|
1 | $5000 |
2 | $3000 |
3 | $10000 |
purchase_id | user_id | product_id | quantity | purchase_date |
---|---|---|---|---|
1 | 10 | 1 | 2 | 01/02/2021 |
2 | 10 | 2 | 1 | 02/02/2021 |
3 | 20 | 1 | 1 | 01/01/2021 |
4 | 20 | 3 | 1 | 02/01/2021 |
5 | 30 | 2 | 2 | 01/12/2021 |
user_id | total_spending | total_quantity |
---|---|---|
20 | $15000 | 2 |
10 | $13000 | 3 |
30 | $6000 | 2 |
This SQL query first joins the purchases and products tables based on the product_id that both exist in both tables. After the join, we limit our focus to the purchases made within the last year using the WHERE clause combined with and . We then calculate the total spending by each user and the total quantity purchased, and we use the GROUP BY clause to group these calculations by user_id. Finally, we sort the output in descending order of total spending to identify the 'whale users'.
To solve a similar power-user data analysis problem question on DataLemur's free online SQL coding environment, try this Microsoft Teams Power User SQL Interview Question:
Textron is a multi-industry company with a global network of aircraft, defense, industrial and finance businesses. We're specifically interested in their aircraft production. The objective is to analyze sales data to see how many aircrafts of each model have been sold per month.
For simplicity's sake, suppose their dataset containing sales information in a table named 'Aircraft_Sales' looks like this:
sale_id | sale_date | model | price |
---|---|---|---|
1 | 01/04/2020 | Cessna 172 | 300000 |
2 | 01/22/2020 | Beechcraft King Air 350 | 7000000 |
3 | 01/28/2020 | Cessna 172 | 300000 |
4 | 02/10/2020 | Cessna 172 | 300000 |
5 | 02/25/2020 | Beechcraft King Air 350 | 7000000 |
Write a SQL query that will provide a breakdown of total sales made for each model for every month. The output should contain - Month, Year, Model, Total_Sales, and Total_Sales_Value.
p.s. To practice a harder variant of this problem, try some of the window functions which show up super frequently during SQL interviews: DataLemur
Stored procedures are a lot like functions in programming. They're used to encapsulate and organize business logic into one unit of code, and they can accept multiple input parameters and return multiple output values.
For example, if you were a Data Analyst at Textron working on a HR analytics project, you might create a stored procedure to calculate the average salary for a given department:
To call this stored procedure and find the average salary for the Data Analytics department you'd write the following query:
Textron is a large multi-industry company, one of its divisions is involved in manufacturing vehicles. Let's suppose you have a table that logs all customer orders for vehicles in Textron's inventory. Write a SQL query that filters down the customer orders made in Texas for SUV/TUV's ordered after Jan 1, 2020 and whose price is an amount greater than $30,000. The filtered output should only contain the customer's names, addresses, the vehicles they ordered, and the order date.
order_id | customer_name | customer_address | state | vehicle_type | order_date | price |
---|---|---|---|---|---|---|
501 | Robert Smith | 123 Pine St, Houston | TX | SUV | 01/15/2020 | $32000 |
502 | Jane Doe | 456 Oak St, Austin | TX | Car | 02/10/2020 | $25000 |
503 | John Doe | 789 Maple St, Dallas | TX | TUV | 12/31/2019 | $35000 |
504 | Alice Johnson | 321 Elm St, San Antonio | TX | SUV | 03/20/2020 | $37000 |
505 | Charlie Brown | 654 Birch St, Houston | AZ | Car | 04/10/2020 | $20000 |
This SQL query uses WHERE to filter the based on the conditions: the state is Texas (), the vehicle type is either SUV or TUV (), the order date is after Jan 1, 2020 () and the vehicle price is above $30,000 (). It selects only the columns , , , and from the records that match these conditions.
There are several normal forms that define the rules for normalizing a database:
A database is in first normal form (1NF) if it meets the following criteria:
A database is in second normal form (2NF) if it meets the following criteria:
Said another way, to achieve 2NF, besides following all the rules from 1NF all the columns in a given table should be dependent only on that table's primary key.
A database is in third normal form (3NF) if it meets the following criteria:
A transitive dependency means that a piece of data in one column is derived from another column. For example, it wouldn't make sense to keep a column called "user's age" and "user's birthdate" (because age can be derived from birthdate.
While there's also a 4th and 5th normal form, it's too pedantic and hence out-of-scope to know for the Textron SQL interview.
The Textron database has a table called where each record represents a customer. The columns in this table include , , , , , , and .
Given this information, can you write a SQL query to find customers whose first name begins with 'Rob'?
customer_id | first_name | last_name | phone | zip_code | join_date | |
---|---|---|---|---|---|---|
547 | Robert | Smith | robertsmith@gmail.com | (555)555-5555 | 90210 | 2019-01-01 |
623 | Robin | Johnson | robinjohnson@yahoo.com | (555)555-1234 | 80206 | 2019-02-15 |
791 | James | Miller | jamesmiller@email.com | (555)555-6789 | 98109 | 2019-03-14 |
802 | Roberto | Martinez | robertomartinez@hotmail.com | (555)555-9876 | 98403 | 2019-04-12 |
919 | Jennifer | Taylor | jennifertaylor@outlook.com | (555)555-4321 | 98102 | 2019-05-01 |
customer_id | first_name | last_name |
---|---|---|
547 | Robert | Smith |
623 | Robin | Johnson |
802 | Roberto | Martinez |
This query works by using the LIKE keyword, along with the '%' wildcard, to filter the table for records where the field begins with 'Rob'. The '%' symbol stands for any number of characters - so this query will return any record where the field starts with 'Rob' followed by any characters. The fields returned are , , and .
Both types of joins in SQL help you retrieve data from multiple tables and merge the results into a single table.
To demonstrate the difference between a left join versus a right join, imagine you had two database tables: an table that contains data on Google Ads keywords and their bid amounts, and a table with information on product sales and the Google Ads keywords that drove those sales.
A retrieves all rows from the left table (in this case, the table) and any matching rows from the right table (the Sales table). If there is no match in the right table, values will be returned for the right table's columns.
A RIGHT JOIN retrieves all rows from the right table (in this case, the Sales table) and any matching rows from the left table (the table). If there is no match in the left table, values will be returned for the left table's columns.
Textron has several products sold worldwide with each having a particular unit price. Each product has an associated unit cost to the company. The sales team logs each sale in a sales database with the quantity sold and the product ID.
You are tasked with calculating the average rounded revenue (unit price * quantity), the profit per unit sold ((unit price - unit cost) * quantity), the square root of the total quantity sold, and the absolute difference between the total quantity sold and the average quantity sold, per product.
product_id | unit_price | unit_cost |
---|---|---|
101 | 500 | 200 |
102 | 350 | 75 |
103 | 200 | 50 |
sale_id | product_id | quantity |
---|---|---|
2013001 | 101 | 5 |
2013002 | 102 | 7 |
2013003 | 103 | 20 |
2013004 | 101 | 8 |
2013005 | 102 | 12 |
p.s. in case this question was tricky, refresh your SQL knowledge with this SQL interview tutorial
The best way to prepare for a SQL interview, besides making sure you have strong SQL fundamentals, is to practice a ton of real SQL questions that were asked in recent job interviews. Beyond just solving the above Textron SQL interview questions, you should also solve the 200+ SQL Interview Questions on DataLemur which come from companies like Microsoft, Google, Amazon, and tech startups.
Each SQL question has hints to guide you, step-by-step solutions and most importantly, there's an interactive coding environment so you can right online code up your SQL query answer and have it graded.
To prep for the Textron SQL interview it is also useful to solve SQL questions from other defense & aerospace contractors like:
In case your SQL foundations are weak, don't worry about going right into solving questions – refresh your SQL knowledge with this interactive SQL tutorial.
This tutorial covers things like aggregate functions like MIN()/MAX() and Self-Joins – both of which show up often in Textron SQL assesments.
For the Textron Data Science Interview, besides SQL questions, the other types of questions which are covered:
The best way to prepare for Textron Data Science interviews is by reading Ace the Data Science Interview. The book's got: