logo

11 Manhattan Associates SQL Interview Questions (Updated 2024)

Updated on

March 1, 2024

At Manhattan Associates, SQL crucial for analyzing large supply chain data sets for optimization and creating performance-scaled data models to support strategic decision-making in logistics. That's why Manhattan Associates asks SQLinterview problems for Data Science, Data Engineering and Data Analytics jobs.

As such, to help you ace the Manhattan Associates SQL interview, we've curated 11 Manhattan Associates SQL interview questions – can you solve them?

Manhattan Associates

11 Manhattan Associates SQL Interview Questions

SQL Question 1: Identify High-Value Customers

Manhattan Associates is keen on identifying their high-value customers in order to optimize their customer relationship efforts. "High-Value" customers, for the scope of this problem, are defined as customers who made purchases of total value over $100,000 in the last 12 months.

As an interviewee, write an SQL query that will return a list of all high-value customers, sorted by the total value of their purchases in descending order.

Consider the following schema for Manhattan Associates' database:

Table:
customer_idfirst_namelast_name
101JohnDoe
102JaneSmith
103BobRoss
104AliceLiu
105CharlieBrown
Table:
order_idcustomer_idpurchase_datetotal_value
10011012021-06-15 00:00:0015000
10021012021-10-28 00:00:0030000
10031022022-01-02 00:00:0045000
10041032022-05-23 00:00:0012000
10051042022-08-01 00:00:0080000

Answer:


This query first joins the "customer" and "orders" tables on the "customer_id" column. It then filters the result set to only include records where the purchase was made less than a year ago. Following this, it groups the result set by customer and calculates the total amount spent by each customer. The "HAVING" clause is used to filter the grouped result set to only show customers who spent more than $100,000. Finally, the result set is ordered by the "total_spent" column in descending order to show the highest spending customers first.

To practice a similar power-user data analysis problem question on DataLemur's free interactive SQL code editor, try this Microsoft Teams Power User SQL Interview Question: Microsoft SQL Interview Question: Teams Super User

SQL Question 2: Average Monthly Sales per Product

Manhattan Associates often requires analysis on their sales data. In the context of this question, we would like to analyze the average quantity sold per product on a monthly basis in the year 2021.

Consider the following dataset, housed in a hypothetical table, which contains individual sales records for Manhattan Associates. Each record details the , , the sold in that transaction, and the .

Example Input:
sale_idproduct_idsale_datequantity
101P10012021-01-1014
102P10022021-01-1550
103P10012021-02-1821
104P10032021-03-2235
105P10022021-02-2845
106P10012021-03-2019
107P10032021-01-0525
108P10012021-02-1517
109P10022021-01-1933

The SQL interview question would be: "Write a SQL query that returns the average monthly quantity sold for each product in the year 2021. The output should have columns for the month, product ID, and the average quantity sold for that product during that month."

Your output should look something like this:

Example Output:
monthproduct_idavg_quantity
1P100114.00
1P100241.50
1P100325.00
2P100119.00
2P100245.00
3P100119.00
3P100335.00

Answer:

Since we're using PostgreSQL, you can make use of the function to get the month from the . Here's a sample SQL query to get the solution:


This query works by first filtering down to sales records just for 2021. It then groups the results by and the month of the sale. Within each group, it calculates the average quantity sold. Finally, it orders the result by and then , so that the sales for each product are grouped together.

Pro Tip: Window functions are a popular SQL interview topic, so practice all the window function problems on DataLemur

SQL Interview Questions on DataLemur

SQL Question 3: What is a database index, and what are the different types of indexes?

An index in a database is a data structure that helps to quickly find and access specific records in a table.

For example, if you had a database of Manhattan Associates customers, you could create a primary index on the column.

Having a primary index on the column can speed up performance in several ways. For example, if you want to retrieve a specific customer record based on their , the database can use the primary index to quickly locate and retrieve the desired record. The primary index acts like a map, allowing the database to quickly find the location of the desired record without having to search through the entire table.

Additionally, a primary index can also be used to enforce the uniqueness of the column, ensuring that no duplicate values are inserted into the table. This can help to prevent errors and maintain the integrity of the data in the table.

Manhattan Associates SQL Interview Questions

SQL Question 4: Identify Customers with High Purchase Levels

Manhattan Associates specializes in supply chain and omnichannel commerce technology. Let's say, they want to identify customers who have purchased items worth more than $1000 in total, and they made these purchases either in their Manhattan office or through their e-commerce channel. Write an SQL query to filter and return these customers.

We have a database, which stores info of each sale made by the company.

Example Input:
sale_idcustomer_idpurchase_datepurchase_valuepurchase_channel
5010012022-06-18560.00E-commerce
5020022022-04-25250.00Manhattan Office
5030012022-05-11475.00E-commerce
5040032022-07-22800.00Third-party Vendor
5050022022-03-05800.00Manhattan Office

Your task is to write a query to filter out the customers who have purchased total worth over $1000 either from Manhattan Office or via E-Commerce.

Example output:
customer_idtotal_purchasepurchase_channel
0011035.00E-commerce
0021050.00Manhattan Office

Answer:


This query filters the table for purchases made via 'E-commerce' or 'Manhattan Office' as specified in the condition. It sums up the purchase values for each customer-channel combination due to clause, then filters these aggregates where total purchase is more than $1000 using condition. In the output, we get the customer_id along with their total purchase amount and the channel they made these purchases from.

SQL Question 5: How do the and window functions differ from each other?

While both and are used to rank rows, the key difference is in how they deal with ties.

RANK(): When there's a tie, leaves a gap in the ranking. For example, if three rows are tied for 2nd place, the RANK() function will assign a rank of 2 to the first of these rows, a rank of 3 to the 2nd row in the tie, and a rank of 4 to the the 3rd tie.

DENSE_RANK(): For ties, does not leave a gap in the ranking. Instead, it assigns the same rank to all tied rows, and then makes the next row 1 bigger. Confusing, I know, but here's an example to make it more clear: if three rows are tied for 3rd place, the function will assign a rank of 3 to all three rows, and then assign a rank of 4 to the next row.

Suppose we had data on how many deals different salespeople at Manhattan Associates:


To rank these salespeople, we could execute the following query:


The result of this query would be:

namedeals_closedrankdense_rank
Akash5011
Brittany5021
Carlos4032
Dave4043
Eve3053
Farhad1064

As you can see, the function assigns a rank of 1 to the first row (Akash), a rank of 2 to the second row (Brittany), and so on. In contrast, the , gives both Akash and Brittany a rank of 1, since they are tied, then moves on to rank 2 for Carlos.

SQL Question 6: Average Time to Resolve Tickets

Manhattan Associates, a technology company providing supply chain management software, amongst other services, would be interested in evaluating their customer service effectiveness. Could you provide the SQL query to find out the average time taken to resolve tickets submitted by customers to their support team?

Assume that we have the following tables and columns:

Example Input:
ticket_idsubmit_dateclose_datecustomer_id
874101/04/2022 00:00:0003/04/2022 00:00:00234
942201/04/2022 00:00:0002/04/2022 00:00:00654
754302/04/2022 00:00:0002/04/2022 00:00:00543
862902/04/2022 00:00:0003/04/2022 00:00:00738

Answer:

Based on the provided input, an SQL query to find out the average resolution time can be as follows:


This SQL query calculates the average resolution time of tickets in days. The function gets the difference between the and in seconds using EPOCH, then converts this to days by dividing by (60 * 60 * 24). The function then calculates the average of these day values. If you want the resolution time in other units like hours or minutes, you can modify the divisor accordingly.

To practice a very similar question try this interactive Facebook Average Post Hiatus (Part 1) Question which is similar for calculating duration between dates or this Amazon Server Utilization Time Question which is similar for estimating total time metrics.

SQL Question 7: Can you describe a cross-join and its purpose?

A cross-join, also referred to as a cartesian join, is a type of JOIN that returns the cross-product of two tables. In a cross-join, each row from the first table is paired with every row from the second table, resulting in a new table with a row for each possible combination of rows from the two input tables.

For example, say you worked on the Marketing Analytics team at Manhattan Associates, and were tasked to understand what advertising copy (text) goes best with what advertising creative (the photo that gets used along with the text copy).

Here is an example of a cross-join between a table of ad_copy and a table of ad_creative:


You could this query to generate all possible combinations of ad copy and ad creative to help you create more effective ads for Manhattan Associates. Just be careful: if you had 1,000 rows of ad copy and 1,000 different image creatives, the resulting cross-join would have 1 million rows! As a result, it's important to use cross-joins judiciously, and make sure that you're not generating more data than you need to.

SQL Question 8: Analysis of Click-Through Rates for Manhattan Associates

You are working as a data analyst for Manhattan Associates, a multinational technology company that provides supply chain management software. One day, you are tasked to analyse and determine the click-through rates of their products.

Given 2 tables, and , which record every time a user clicks on an advertisement for a product, and every time a user subsequently adds that product to their cart, write a query to find the click-through conversion rate for each product.

Example Input:

Example Input:

Answer:


The above PostgreSQL query returns the click-through conversion rate which is the ratio of the number of times a product is added to the cart to the number of times an advertisement for the product is clicked for each product. This is achieved by joining two subqueries on product_id. The first subquery, , calculates the count of ad clicks on each product, and the second subquery, , calculates the count of add-to-cart actions on each product.

To solve a similar problem on DataLemur's free online SQL coding environment, solve this Facebook SQL Interview question: Meta SQL interview question

SQL Question 9: Calculate total ordered quantities from a given vendor

You are asked to analyze a sales database of Manhattan Associates. You have two tables, and . The table contains orders placed by customers, including the of the ordered product and the quantity ordered. The table lists all the available products, their , , and the that supplies the product.

Write a SQL query that joins these two tables and calculates the total quantities of products ordered from a given vendor ().

The expected output should have the , and the of all ordered for each product from that vendor.

Example Input:

order_idproduct_idquantity
90011000110
90021000215
90031000120
90041000310
9005100035

Example Input:

product_idproduct_namevendor_id
10001Apples123
10002Bananas123
10003Cherries456

Example Output:

vendor_idproduct_nametotal_quantity
123Apples30
123Bananas15

Answer:


In this query we are joining the and table on the . We filter the results to only include products from the vendor with 123. Then we use the clause to group the results by and and simultaneously summing the column to find the total quantity of products ordered from a specific vendor.

Because joins come up frequently during SQL interviews, try this interactive Snapchat Join SQL question: Snapchat JOIN SQL interview question

SQL Question 10: What does do, and when would you use this SQL command?

When using , only rows that are identical in both sets will be returned.

For a concrete example, say you were a Data Analyst supporting the Sales Analytics team at Manhattan Associates, and data on potential sales leads lived in both Salesforce and Hubspot CRMs. To write a query to analyze leads created before 2023 started, that show up in BOTH CRMs, you would use the command:


SQL Question 11: Calculate the Squared Distance from Average Sales

The sales department of Manhattan Associates tracks the sales of each product on a quarterly basis and stores it in a database. You are asked to analyze the variance related to the average sales for each category during the last year. Variances are often analyzed by looking at the square of the difference from mean (average). Create a SQL query that calculates the squared distance of each product's quarterly sales from the average sales of its category. For this, extract the category, product_id, quarter, actual sales, average category sales for the year, and the squared difference between actual and average sales.

Be sure to use the following math functions in your SQL query: AVG(), POWER(), ROUND().

Example Input:
product_idcategoryquartersales
1001Electronics11300
1002Electronics11500
1003Furniture13200
1001Electronics21200
1002Electronics21100
1003Furniture22900
1001Electronics31400
1002Electronics31300
1003Furniture33100
1001Electronics41500
1002Electronics41700
1003Furniture42800

Answer:


This query first calculates the average sales of each category for each quarter in the subquery called . Then it joins this table with the original table so that each row has the sales of the product and the average sales of the category for the corresponding quarter. The squared distance is calculated by subtracting the sales of the product from the average sales, squaring it using the POWER() function, and rounding to 2 decimal places.

Note: In real world, you would also consider number of products in each category and the number of quarters to keep this fair.

To practice a very similar question try this interactive Wayfair Y-on-Y Growth Rate Question which is similar for handling sales data or this Amazon Highest-Grossing Items Question which is similar for analysing sales per product.

How To Prepare for the Manhattan Associates SQL Interview

Assuming that you've already got basic SQL skills, the next best tip we have to prepare for the Manhattan Associates SQL interview is to solve as many practice SQL interview questions as you can! Beyond just solving the above Manhattan Associates SQL interview questions, you should also solve the 200+ FAANG SQL Questions on DataLemur which come from companies like Google, Microsoft and Silicon Valley startups. DataLemur SQL Interview Questions

Each exercise has hints to guide you, detailed solutions and crucially, there is an online SQL code editor so you can easily right in the browser your SQL query and have it graded.

To prep for the Manhattan Associates SQL interview you can also be wise to practice interview questions from other tech companies like:

However, if your SQL query skills are weak, forget about going right into solving questions – improve your SQL foundations with this free SQL for Data Analytics course.

SQL tutorial for Data Analytics

This tutorial covers SQL concepts such as filtering groups with HAVING and manipulating date/time data – both of which come up frequently during Manhattan Associates SQL assessments.

Manhattan Associates Data Science Interview Tips

What Do Manhattan Associates Data Science Interviews Cover?

In addition to SQL query questions, the other question categories to practice for the Manhattan Associates Data Science Interview are:

  • Probability & Statistics Questions
  • Python or R Programming Questions
  • Product Analytics Questions
  • ML Interview Questions
  • Behavioral Based Interview Questions

Manhattan Associates Data Scientist

How To Prepare for Manhattan Associates Data Science Interviews?

The best way to prepare for Manhattan Associates Data Science interviews is by reading Ace the Data Science Interview. The book's got:

  • 201 Interview Questions from FAANG tech companies
  • A Refresher covering Product Analytics, SQL & ML
  • Great Reviews (900+ reviews, 4.5-star rating)

Ace the DS Interview