Cintas employees use SQL daily for analyzing uniform rental patterns and inventory management. Which is why Cintas covers SQL query questions during interviews for Data Science and Data Engineering positions.
So, to help you study, here's 8 Cintas SQL interview questions – able to solve them?
Cintas is a company that provides a range of products and services to businesses such as uniforms, janitorial supplies, safety & compliance training, and Business Protection Services (fire and security solutions). For this question, let's assume that you're analyzing the uniform sales department.
As a data analyst, you are asked to compile a monthly report for the last year by the head office. This report needs to show the total number of uniform pieces sold each month per department and the average sale per item in each department. You have access to the sales data of each transaction.
Here is your database table named .
sales_id | sales_date | department_id | num_of_uniforms | total_sale |
---|---|---|---|---|
8765 | 2021-04-10 | 001 | 10 | 200.00 |
5210 | 2021-04-28 | 002 | 50 | 450.00 |
5931 | 2021-06-16 | 001 | 30 | 660.00 |
3504 | 2021-11-25 | 002 | 60 | 540.00 |
2486 | 2022-01-18 | 001 | 20 | 400.00 |
Your task is to write a SQL query to create this report. The output should look like this. The date should be in the 'yyyymm' format.
month_year | department_id | total_num_of_uniforms | avg_sale_per_item |
---|---|---|---|
202104 | 001 | 10 | 20.00 |
202104 | 002 | 50 | 9.00 |
202106 | 001 | 30 | 22.00 |
202111 | 002 | 60 | 9.00 |
202201 | 001 | 20 | 20.00 |
In PostgreSQL, you can use the function to get the month and year part of a date, and and function to calculate the average sale per uniform item. Here is the query that solves the problem:
This query first truncates the to the month and formats it as 'YYYYMM'. Then it groups the sales by and to calculate the total number of pieces sold and the average sale per item in each month for each department. It then rounds the average sale per item to 2 decimal places using the function.
For more window function practice, try this Uber SQL Interview Question on DataLemur's online SQL code editor:
Imagine there was a table of Cintas employee salary data. Write a SQL query to find the top three highest paid employees within each department.
employee_id | name | salary | department_id |
---|---|---|---|
1 | Emma Thompson | 3800 | 1 |
2 | Daniel Rodriguez | 2230 | 1 |
3 | Olivia Smith | 2000 | 1 |
4 | Noah Johnson | 6800 | 2 |
5 | Sophia Martinez | 1750 | 1 |
8 | William Davis | 6800 | 2 |
10 | James Anderson | 4000 | 1 |
department_id | department_name |
---|---|
1 | Data Analytics |
2 | Data Science |
department_name | name | salary |
---|---|---|
Data Analytics | James Anderson | 4000 |
Data Analytics | Emma Thompson | 3800 |
Data Analytics | Daniel Rodriguez | 2230 |
Data Science | Noah Johnson | 6800 |
Data Science | William Davis | 6800 |
You can solve this question interactively on DataLemur:
We use the DENSE_RANK() window function to generate unique ranks for each employee's salary within their department, with higher salaries receiving lower ranks. Then, we wrap this up in a CTE and filter the employees with a ranking of 3 or lower.
If the code above is tough, you can find a detailed solution here: Top 3 Department Salaries.
Also read about how Cintas generates the next generation of leadership!
"The clause in SQL allows you to select records that are unique, eliminating duplicates.
For a tangible example, say you had a table of Cintas employees:
first_name | job_title |
---|---|
Akash | Data Analyst |
Brittany | Data Scientist |
Carlos | Data Engineer |
Diego | Data Engineer |
Eva | Data Analyst |
If you were doing an HR Analytics project and you wanted to get all the unique job titles that currently worked at the company, you would write the following SQL query:
The output would give you 3 distinct job titles at Cintas:
job_title |
---|
Data Analyst |
Data Scientist |
Data Engineer |
Cintas is a company that provides specialized services to businesses, including uniform rental and supply. For each location, they maintain inventory for numerous products.
In this question, you are required to find out the average number of units used per location for each product across all the locations, during a year.
product_id | location_id | year | units_used |
---|---|---|---|
1001 | 001 | 2020 | 500 |
1001 | 002 | 2020 | 400 |
1001 | 003 | 2020 | 600 |
1002 | 001 | 2020 | 200 |
1002 | 002 | 2020 | 250 |
1002 | 003 | 2020 | 300 |
product_id | product_name |
---|---|
1001 | Uniform |
1002 | Towels |
product | average_units_used_per_location |
---|---|
Uniform | 500 |
Towels | 250 |
In this query, we join the inventory table with the products table on the product_id. We then filter the records for the year 2020. Using the AVG function, we compute the average units used per location for each product. The GROUP BY clause is used to group the records by product name.
To practice a very similar question try this interactive Amazon Highest-Grossing Items Question which is similar for inventory and product analysis or this CVS Health Pharmacy Analytics (Part 1) Question which is similar for average calculation across locations.
A is a field in a table that references the of another table. It creates a link between the two tables and ensures that the data in the field is valid.
Say for example you had sales analytics data from Cintas's CRM (customer-relationship management) tool.
In this example, the table has a foreign key field called that references the "account_id" field in the table (the primary key). This helps to link the data about each opportunity to the corresponding account information in the accounts table.
This makes sure the insertion of rows in the table that do not have corresponding entries in the table. It also helps to enforce the relationship between the two tables and ensures that data is not deleted from the table if there are still references to it in the table.
Cintas Corporation is a business services company. Suppose you are a data analyst at Cintas and are interested in understanding the effectiveness of advertisements displayed across various websites. In particular, you are tasked to determine the click-through-rate (CTR) for each website in the past one month. Further, you are also interested in understanding the conversion rate (how many clicked ads led to a real sale).
To answer these questions, we will consider two tables - and .
click_id | ad_id | date | website |
---|---|---|---|
101 | 4005 | 06/10/2022 00:00:00 | Yahoo |
102 | 3205 | 06/10/2022 00:00:00 | |
103 | 4005 | 06/16/2022 00:00:00 | Yahoo |
104 | 2002 | 06/20/2022 00:00:00 | MSN |
105 | 2002 | 06/30/2022 00:00:00 | MSN |
conversion_id | click_id | sales_amt |
---|---|---|
39 | 101 | 150.00 |
40 | 102 | 250.00 |
41 | 104 | 120.00 |
We are interested in understanding the total click-through rate and conversion rate for each website.
In the above solution, we first calculate the total number of ad clicks () per website for a given one month period in the CTE.
Next, we calculate the total number conversions () per website for the same time period in the CTE.
Finally, we perform a left join on these two tables on the column and calculate the by dividing by . We also calculate the by dividing by the sum of over all websites. Both rates are presented as percentages.
This query gives us both the click-through rate and conversion rate for each website where the ads were displayed. This data can be used to understand the return on investment for advertising on each website and also to guide future advertising decisions.
To solve a related problem on DataLemur's free interactive SQL code editor, attempt this SQL interview question asked by Facebook:
Note: interviews at Cintas often aren't trying to test you on a specific flavor of SQL. As such, you don't need to exactly know that is available in PostgreSQL and SQL Server, while MINUS is available in MySQL and Oracle – you just need to know the general concept!
Your answer should mention that the / operator is used to remove to return all rows from the first SELECT statement that are not returned by the second SELECT statement.
Here's a PostgreSQL example of using EXCEPT to find all of Cintas's Facebook video ads with more than 50k 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.
You're working for Cintas, a company that provides specialized services to businesses, including uniform rental and cleaning services. The company has a wide customer database and different service locations. Your task is to write a SQL query to filter the database so you only retrieve customers whose service location starts with 'San' (This means any location that starts with 'San' such as 'San Diego', 'San Francisco' etc.)
For simplicity, let's consider the customer records database has the following structure:
customer_id | customer_name | service_location | service_type | start_date |
---|---|---|---|---|
125 | McDonalds | San Diego | Uniform Rental | 2015-03-09 |
678 | Starbucks | New York | Cleaning Services | 2017-06-27 |
231 | In-N-Out | San Francisco | Uniform Rental | 2016-12-03 |
900 | Burger King | Los Angeles | Cleaning Services | 2017-11-14 |
754 | Subway | San Antonio | Uniform Rental | 2018-05-21 |
To filter the customers whose service location starts with 'San', you can use the SQL statement:
This query will return the records of the customers with a service location starting with 'San'. The '%' symbol is a wildcard character that matches any sequence of characters.
customer_id | customer_name | service_location | service_type | start_date |
---|---|---|---|---|
125 | McDonalds | San Diego | Uniform Rental | 2015-03-09 |
231 | In-N-Out | San Francisco | Uniform Rental | 2016-12-03 |
754 | Subway | San Antonio | Uniform Rental | 2018-05-21 |
The SQL query has filtered the database to return only those customers whose service location starts with 'San'. It enables Cintas to easily get insight into their customers in 'San' locations and provides a starting point for further data analysis.
The key to acing a Cintas SQL interview is to practice, practice, and then practice some more! In addition to solving the above Cintas SQL interview questions, you should also solve the 200+ tricky sql questions on DataLemur which come from companies like Amazon, Microsoft, Meta, and smaller tech companies.
Each problem on DataLemur 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 right online code up your SQL query and have it graded.
To prep for the Cintas SQL interview it is also helpful to practice SQL questions from other apparel companies like:
But if your SQL query skills are weak, don't worry about going right into solving questions – go learn SQL with this SQL tutorial for Data Analytics.
This tutorial covers things like aggregate functions like SUM()/COUNT()/AVG() and WHERE vs. HAVING – both of which come up frequently in Cintas SQL assessments.
Beyond writing SQL queries, the other types of problems to practice for the Cintas Data Science Interview are:
The best way to prepare for Cintas Data Science interviews is by reading Ace the Data Science Interview. The book's got: