8 Descartes SQL Interview Questions (Updated 2024)

Updated on

March 2, 2024

At Descartes Systems, SQL is used day-to-day for analyzing massive datasets to improve logistics efficiency and manage supply chain operations. So, it shouldn't surprise you that Descartes typically asks SQL questions during interviews for Data Science, Data Engineering and Data Analytics jobs.

So, to help you ace the Descartes SQL interview, this blog covers 8 Descartes Systems SQL interview questions – can you answer each one?

8 Descartes Systems SQL Interview Questions

SQL Question 1: Calculate the monthly average rating for each product

In Descartes, we have a table which has the customer reviews containing the information of the product reviewed, the review's ID, user's ID, the number of stars given from 1-5, and the date when the review was submitted.

Write a SQL query which will calculate the average number of stars each product received each month. Ranking should be based on the year and month of submit_date.

Example Input:


Example Output:


This SQL query calculates monthly average rating for each product. It first truncates the date by month, giving the first day of the month for each date. Then it forms groups by these truncated dates and product ids to calculate average stars. The output is ordered by month and product id.

Pro Tip: Window functions are a popular SQL interview topic, so practice every window function problem on DataLemur

SQL Interview Questions on DataLemur

SQL Question 2: Design Database for Order Management System

Descartes is well-known for its logistics and supply chain solutions. One main function of the software is to track orders throughout the supply chain system. Your task is to model a database structure for this order system.

To adhere to the business process, the following entities are crucial: Customers (who places an order), Products (which is ordered) and Suppliers (who supply the Products). An Order is placed by a Customer for one or several Product(s) which are supplied by a Supplier(s).

Consider following attributes for the entities:

  • Customers: customer_id, first_name, last_name, email
  • Products: product_id, product_name, supplier_id
  • Suppliers: supplier_id, supplier_name

Orders are placed on a specific date by the customers and each order consists of different products with their quantities.

Create a database table with attributes: order_id, customer_id, order_date, product_id, quantity.

Sample Input:


Write a PostgreSQL query to retrieve the total quantity of each product ordered by each customer.


This query groups orders by customer and product to get the total quantity of each product ordered by each customer. By using the aggregate function on the column and grouping by and , we can sum up the total quantity for each product for each customer. The clause is then used to sort the results by and .

SQL Question 3: What does / SQL commands do?

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 Descartes should be lenient!).

For a tangible example in PostgreSQL, suppose you were doing an HR Analytics project for Descartes, and had access to Descartes'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:

Descartes Systems SQL Interview Questions

SQL Question 4: Average Time Spent per Session

As a data analyst at Descartes, a software technology company that provides on-demand, software-as-a-service solutions, you are asked to study users' software interaction times. To evaluate the efficiency of the recently updated interface, you've been tasked to find the average time spent per user session.

Consider the following data:

Example Input:
10112306/10/2022 10:00:0006/10/2022 10:30:00
10212306/10/2022 11:00:0006/10/2022 11:45:00
10345606/12/2022 13:00:0006/12/2022 13:15:00
10445606/12/2022 15:00:0006/12/2022 15:35:00
10512306/13/2022 09:00:0006/13/2022 09:45:00


In this query, we calculate the time spent per session by subtracting the start_time from the end_time. We then use the AVG function to find the average time spent per session for each user. The time difference between end_time and start_time in PostgreSQL yields an INTERVAL type, hence we use the EXTRACT function to convert this interval to seconds (EPOCH), then divide by 60 to get minutes. We round this value to two decimal places for a more readable format.

The 2 most similar questions are:

  1. "Sending vs. Opening Snaps": This problem is similar as it involves calculating time spent on activities, like the task of finding the average time spent per session.

  2. "Server Utilization Time": This problem also involves calculating total time for a particular activity. This reflects similar operations to find the average time spent per session.

Here is the markdown content:

To practice a very similar question try this interactive Snapchat Sending vs. Opening Snaps Question which is similar for calculating time spent on activities or this Amazon Server Utilization Time Question which is similar for calculating total time for a particular activity.

SQL Question 5: In SQL, are NULLs treated the same as zero's and blank spaces?

In SQL, a value is NOT the same as a zero or a blank space. A NULL value represents the absence of a value or a missing value, whereas both zero and blank space are actually values.

To handle nulls, the function is often used to check for a null, and if there is a null, you can assign a default value.

SQL Question 6: Analyzing Click-through Rates for Descartes

Descartes, a SaaS (Software as a Service) company has recently launched a marketing campaign. They are primarily interested in understanding the click-through rates (CTR) of their ads leading users to add products to a cart. Your task is to determine the CTR which is calculated as the number of ‘add to cart’ actions divided by the number of ad views, multiplied by 100 to get a percentage. Provide the result for each ad campaign.

Example Input:
Example Input:


This query calculates the CTR by joining and tables on and . It then calculates the ratio of how many of ad views resulted in an ‘add to cart’ action. This ratio is multiplied by 100 to get a percentage, giving us the click-through rate for each ad campaign.

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

SQL Question 7: What's the difference between and ?

The clause is used to filter the groups created by the clause. It's similar to the clause, but it is used to specify conditions on the groups created by the clause, rather than on the individual rows of the table.

For example, say you were analyzing salaries for analytics employees at Descartes:

This query retrieves the total salary for each Analytics department at Descartes and groups the rows by the specific department (i.e. "Marketing Analytics", "Business Analytics", "Sales Analytics" teams).

The clause then filters the groups to include only Descartes departments where the total salary is greater than $1 million

SQL Question 8: Average Delivery Time Per Month

Descartes is a technology company that provides logistics and supply chain management solutions. For this interview question, imagine that you are provided with a table that records all shipments made by the company. The table contains a , , , and .

Your task is to write a SQL query that calculates the average delivery time (in days) for each month.

Example Input:
Example Output:


In this query, we first extract the month from the using the function. Then, we calculate the average delivery time by subtracting the from the and using the function to convert the result into days. Finally, we group by the month and order the result by month.

Preparing For The Descartes SQL Interview

Assuming that you've already got basic SQL skills, the next best tip we have to prepare for the Descartes SQL interview is to solve as many practice SQL interview questions as you can! Besides solving the above Descartes SQL interview questions, you should also solve the 200+ tricky sql questions on DataLemur which come from companies like Google, Uber, and Microsoft. DataLemur SQL and Data Science Interview Questions

Each DataLemur SQL question 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 Descartes SQL interview it is also useful to solve SQL questions from other tech companies like:

In case your SQL coding skills are weak, don't worry about jumping right into solving questions – refresh your SQL knowledge with this SQL interview tutorial.

DataLemur SQL Tutorial for Data Science

This tutorial covers things like inner vs. outer JOIN and CASE/WHEN/ELSE statements – both of which pop up routinely during SQL job interviews at Descartes.

Descartes Systems Data Science Interview Tips

What Do Descartes Data Science Interviews Cover?

In addition to SQL query questions, the other types of problems to prepare for the Descartes Data Science Interview are:

  • Statistics and Probability Questions
  • Coding Questions in Python or R
  • Open-Ended Data Case Studies
  • ML Interview Questions
  • Behavioral Interview Questions

Descartes Data Scientist

How To Prepare for Descartes Data Science Interviews?

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

  • 201 Interview Questions from tech companies like Google & Microsoft
  • A Crash Course on SQL, Product-Sense & ML
  • Amazing Reviews (900+ reviews, 4.5-star rating)

Ace the Data Science Interview by Nick Singh Kevin Huo