11 McDonald's SQL Interview Questions (Updated 2024)

Updated on

October 31, 2024

McDonald's employees write SQL queries to analyze customer behavior patterns, helping them understand what menu items are popular at different times of the day and how promotions impact sales. It also allows them to optimize supply chain management by analyzing historical sales data to ensure they have the right ingredients in stock when demand peaks, this is why McDonald's asks SQL questions during interviews for Data Analyst, Data Science, and BI jobs.

Thus, to help you study, we've curated 11 McDonald's SQL interview questions – able to answer them all?

McDonald's SQL Interview Questions

11 McDonald's SQL Interview Questions

SQL Question 1: Analyze Sales Performance of Different Menu Items.

You are given a table named in which each row represents one order details at a McDonald's outlet. The columns include the , , (the date the item was sold), and (price of the ordered item).

Write a SQL query to find the monthly total sales of each item and rank them within each month based on the total sales. You should use window functions in your query.

Example Input:

order_iditem_idsales_dateprice
10112022-06-035.99
10222022-06-034.99
10312022-06-045.99
10432022-06-043.99
10522022-07-014.99
10632022-07-023.99
10712022-07-025.99

Example Output:

mthitem_idtotal_salesrank
6111.981
624.992
633.993
715.991
724.992
733.993

Answer:


In this query, is applied to divide the sales table into sub-tables for each item's monthly sales.

is then applied to calculate the total sales for each item each month, and function is used to assign a ranking to each item within each month based on their total sales.

To practice another window function question on DataLemur's free online SQL code editor, solve this Amazon SQL question asked in a BI Engineer interview:

Amazon SQL Interview Question

Check out McDonald's press releases to learn about their ongoing efforts to innovate and adapt in the fast-food industry! This information is relevant for understanding how McDonald's is evolving to meet changing consumer preferences and expectations.

SQL Question 2: Employee Salaries Higher Than Their Manager

Imagine there was a table of McDonald's employee salary data. Write a SQL query to find the employees who earn more than their direct manager.

McDonald's Example Input:

employee_idnamesalarydepartment_idmanager_id
1Emma Thompson38001
2Daniel Rodriguez2230110
3Olivia Smith800018
4Noah Johnson680028
5Sophia Martinez1750110
8William Davis70002NULL
10James Anderson40001NULL

Example Output:

employee_idemployee_name
3Olivia Smith

This is the output because Olivia Smith earns $8,000, surpassing her manager, William Davis who earns 7,800.

Check your SQL query for this question and run your code right in DataLemur's online SQL environment:

Employees Earning More Than Their Manager

Answer:

First, we perform a SELF-JOIN where we treat the first table () as the managers' table and the second table () as the employees' table. Then we use a clause to filter the results, ensuring we only get employees whose salaries are higher than their manager's salary.


If the solution above is hard to understand, you can find a step-by-step solution here: Employee Salaries Higher Than Their Manager.

SQL Question 3: What are the various forms of normalization?

Normalization is the process of organizing fields and tables of a database to minimize redundancy and dependency. While there are technically 5 levels (normal forms), the 3 most important normal forms you need to know about for SQL interviews at McDonald's are:

  1. First Normal Form (1NF): This should fix remove a table's duplicate columns. Also, each column should contain only a single value (no lists or containers of data), and finally each row of table should have a unique identifier as well.
  2. Second Normal Form (2NF): A table is in its second normal form if it meets all requirements of the first normal form and places the subsets of columns in separate tables. The relationships between tables are created using primary/foreign keys.
  3. Third Normal Form (3NF): The table should be in the second normal form. There should be no dependency on another non-key attribute (meaning a primary key should be the only thing required to identify the row).

McDonald's SQL Interview Questions

SQL Question 4: Analyze the Sales of McDonald's

The McDonald's Corporation wants to analyze their sales data to gain insights that could potentially lead to strategic business decisions. They want to know which burger type sold the most in each city along with the total revenue earned from its sales. They also want to know which city had the highest sales.

Assume that the McDonald's Corporation has its business data spread across three separate tables: , and . The table contains details about the various burger types that the corporation offers. The table contains details about the sales made at each branch. The table contains details about the various branches of the corporation.

Example Input:

burger_idburger_typeprice
1Big Mac3.99
2Quarter Pounder3.79
3Cheeseburger1.69

Example Input:

sale_idburger_idbranch_idquantity
111100
212150
32180

Example Input:

branch_idcity
1New York
2Chicago

Answer:


This query joins the , and tables on their common fields ( and ). It then groups the result by and . Finally, it calculates the total revenue for each in each and orders the result in descending order of . This way, for every city, we get the burger type that has the most sales along with the total revenue generated.

To get the city with highest sales, we could simply group by city and sum the total revenues, ordering the result in descending order of the total revenues.

SQL Question 5: Can you explain the concept of a cross-join, and their purpose?

A cross-join, also known as a cartesian join, is a type of JOIN operation in SQL that creates a new table by combining each row from the first table with every row from the second table. This results in a table with a row for every possible combination of rows from the two input tables.

An example of when this might be useful is if you wanted to first make a dataset containing all possible pairs of customers and products data, in order to later build a Machine Learning model to predict the probability of a customer purchasing a particular product.


However, it is important to note that cross-joins can create very large tables, especially if the input tables have a large number of rows. For example, if you had 10,000 customers and 5,000 different product SKUs, the resulting cross-join would have 50 million rows.

SQL Question 6: Filtering McDonald's Customers by Preferences and Histories

As an analyst in McDonald's, we want to tailor our menu and offers to cater to our loyal customers. To do so, we need to filter customers who ordered meals at least twice in the last month and prefer 'non-vegetarian' meals.

The and tables have the following schema:

Example Input:

order_idcustomer_idmeal_idorder_date
10012013012022-02-10
10022023022022-02-15
10032013012022-02-18
10042033022022-03-01
10052043032022-03-02
10062013032022-03-05
10072043032022-03-10

Example Input:

customer_idpreference
201Non-vegetarian
202Vegetarian
203Non-vegetarian
204Non-vegetarian

Note: In the table, each row represents an order placed by a customer. In the table, the column indicates whether the customer prefers vegetarian or non-vegetarian meals.

Answer:


With this query, we first join the and tables using the column. We then filter the records to only include orders placed within February 2022 and those who prefer non-vegetarian meals. Finally, we group by and and restrict the results to only include customers who made 2 or more orders within the specified period, as per the requirements.

SQL Question 7: How can you select records without duplicates from a table?

The keyword added to a statement can be used to get records without duplicates.

For example, say you had a table of McDonald's customers:

namecity
AkashSF
BrittanyNYC
CarlosNYC
DiegoSeattle
EvaSF
FayeSeattle

Suppose you wanted to figure out which cities the customers lived in, but didn't want duplicate results, you could write a query like this:


Your result would be:

city
SF
NYC
Seattle

SQL Question 8: Average sales per McDonald's menu item

As a data analyst for McDonald's, we want to understand which are our most favourite items. Write a SQL query to find out the average daily sales for each item on the McDonald's menu.

Example Input:

dateitem_idquantity
2022-08-011300
2022-08-012150
2022-08-021400
2022-08-022200
2022-08-023100
2022-08-031350
2022-08-033120

Example Input:

item_iditem_name
1Big Mac
2Quarter Pounder
3Chicken McNuggets

Example Output:

item_nameavg_daily_sales
Big Mac350
Quarter Pounder175
Chicken McNuggets110

Answer:


This query joins the and tables on the column. Then, it groups data by the and calculates the average quantity (which represents daily sales) for each group (menu item). The result is the average daily sales for each item on McDonald's menu.

To practice a very similar question try this interactive Amazon Highest-Grossing Items Question which is similar for identifying most popular products or this Wayfair Y-on-Y Growth Rate Question which is similar for analyzing daily sales data.

SQL Question 9: Calculate the Click-Through-Rate for McDonald's Digital Ads

McDonald's is executing digital promotional campaigns for their new burger. These campaigns are showing ads to customers through various platforms. Each ad comes with a click-through link. When the customer clicks on this link, they are directed to McDonald's app where they have an option to add the new burger to the cart.

Write a SQL query that calculates the Click-Through-Rate (CTR) which is defined as the number of users who clicked the ad link (clicks) divided by the number of users the ad was shown to (impressions). Also, calculate the Conversion Rate (CR) defined as the number of users who added the burger to the cart (conversions) divided by the total number of ad-clicks.

We have two tables:

Example Input:

ad_idimpressions
15000
24500
36000

Example Input:

click_iduser_idad_id
11231
22651
33622
41923
59813

Example Input:

cart_iduser_id
1123
2362
3192

The output should be:

Example Output:

ad_idCTRCR
10.00040.5
20.000221
30.000330.5

Answer:

The SQL query for this problem would be:


This query first joins the , , and tables using LEFT JOINs. Then, for each , it calculates the CTR as the total number of clicks divided by the number of impressions, and the CR as the total number of carts divided by the number of clicks. The is used to cast the integer counts to floating point values, ensuring a decimal result.

To solve a similar SQL problem on DataLemur's free interactive SQL code editor, solve this Meta SQL interview question:

SQL interview question asked by Facebook

SQL Question 10: What do the SQL commands / do?

For a tangible example of in PostgreSQL, suppose you were doing an HR Analytics project for McDonald's, and had access to McDonald's's contractors and employees data. Assume that some employees were previously contractors, and vice versa, and thus would show up in both tables.

You could use operator to find all contractors who never were a employee using this query:


Note that is available in PostgreSQL and SQL Server, while is the equivalent operator which is available in MySQL and Oracle (but don't worry about knowing which RDBMS supports which exact commands since McDonald's interviewers aren't trying to trip you up on memorizing SQL syntax).

SQL Question 11: Finding Orders Containing Specific Menu Items

As a data analyst at McDonald's, your role is to study order patterns to measure the popularity of different menu items. Write a SQL query that finds all orders which include a menu item that contains the word 'Burger'.

Below are two tables, and .

Example Input:

order_idcustomer_idorder_datemenu_id
10112306/08/20221
10226506/10/20222
10336206/18/20223
10419207/26/20224
10598107/05/20225

Example Input:

menu_iditem_name
1Big Mac Burger
2Chicken McNuggets
3Fish-O-Fillet
4Quarter Pounder Burger
5McFlurry

Your output should include the , , and .

Answer:


This query joins the and tables on , then selects relevant columns. It only includes rows where the in the table contains 'Burger'.

McDonald's SQL Interview Tips

The best way to prepare for a McDonald's SQL interview is to practice, practice, practice. Besides solving the earlier McDonald's 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.

DataLemur Question Bank

Each exercise has multiple hints, 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 easily right in the browser your query and have it graded.

To prep for the McDonald's SQL interview it is also helpful to practice interview questions from other hospitality and restaurant companies like:

However, if your SQL coding skills are weak, forget about diving straight into solving questions – strengthen your SQL foundations with this DataLemur SQL tutorial.

SQL tutorial for Data Analytics

This tutorial covers SQL concepts such as CASE/WHEN/ELSE statements and different types of joins – both of which show up often in SQL interviews at McDonald's.

McDonald's Data Science Interview Tips

What Do McDonald's Data Science Interviews Cover?

In addition to SQL interview questions, the other types of questions tested in the McDonald's Data Science Interview are:

McDonald's Data Scientist

How To Prepare for McDonald's Data Science Interviews?

I believe the best way to study for McDonald's Data Science interviews is to read the book Ace the Data Science Interview.

It has 201 data interview questions taken from FAANG & startups. The book's also got a crash course on SQL, Product-Sense & ML. And finally it's helped thousands of people land their dream job in data, which is how it's gotten to be an Amazon best-seller with over 1000+ 5-star reviews.

Ace the Data Science Interview by Nick Singh Kevin Huo

While the book is more technical in nature, it's also crucial to prepare for the McDonald's behavioral interview. Start by reading the company's unique cultural values.

© 2025 DataLemur, Inc

Career Resources

Free 9-Day Data Interview Crash CourseFree SQL Tutorial for Data AnalyticsSQL Interview Cheat Sheet PDFUltimate SQL Interview GuideAce the Data Job Hunt Video CourseAce the Data Science InterviewBest Books for Data AnalystsSQL Squid Game