11 Pinterest SQL Interview Questions

Updated on

January 22, 2024

At Pinterest, SQL does the heavy lifting for analyzing user engagement trends and for managing their MySQL fleet. Because of this, Pinterest almost always asks SQL query questions during interviews for Data Analytics, Data Science, and Data Engineering jobs.

In case you're trying to prepare for the SQL Assessment, here’s 11 Pinterest SQL interview questions to practice, which are similar to recently asked questions at Pinterest – can you solve them?

Pinterest SQL Interview Questions

11 Pinterest SQL Interview Questions

SQL Question 1: User Concurrent Sessions

Assume you're given a table containing information about user sessions, including the start and end times of each session. Write a query to retrieve the user session(s) that occur concurrently with the other user sessions.

Output the session ID and the number of concurrent user sessions, sorted in descending order.


  • Concurrent sessions are defined as sessions that overlap with each other. For instance, if session 1 starts before session 2, session 2's start time should fall either before or after session 1's end time.
  • Sessions with identical start and end times should not be considered concurrent sessions.
Column NameType
Example Input:
74638201/02/2024 12:00:0002/01/2024 16:48:00
14314501/02/2024 14:25:0002/01/2024 15:05:00
13451401/02/2024 15:23:0002/01/2024 18:15:00
24235401/02/2024 21:34:0003/01/2024 00:11:00
14325601/06/2024 06:55:0001/06/2024 09:05:00
Example Output:

Session 746382 has 2 concurrent sessions: session_id 134514 and 242354.

  • Session 746382 ends at 02/01/2024 16:48:00, which is before session 134514's end time of 02/01/2024 18:15:00.
  • Additionally, session 746382 ends before session 242354's end time of 03/01/2024 00:11:00.

These comparisons indicate that session 746382 overlaps with both sessions 134514 and 242354 since its end time is earlier than the end times of both concurrent sessions.

DataLemur Premium subscribers can try this problem interactively in the browser:

Pinterest SQL Interview Question: User Concurrent Sessions


For a step-by-step solution, subscribe to DataLemur Premium to unlock this Pinterest SQL Question & Solution.

SQL Question 2: Pinterest Image Pins Statistics

Write a SQL query to find the average number of pins a user pins, and the difference between the current average pin count and the previous month average pin count for specific users.

Given the table representing the pins users added to their boards.

Example Input:
Example Output:


This query calculates the total number of pins a users pins each month by using the clause. To calculate the difference in pins from the previous month we use the and to retrieve the count from the previous row (which is the previous month due to our order by clause), and subtract it from the current month's count.

To practice a similar window function interview problem which uses RANK() on DataLemur's free online SQL code editor, solve this Amazon SQL question asked in a BI Engineer interview:

Amazon Highest-Grossing Items SQL Analyis Question

SQL QUESTION 3: Can you explain the distinction between cross join and natural join?

Cross join and natural join are like two sides of a coin in the world of SQL.

Cross joins is like the wild and reckless cousin who creates a giant new table by combining every row from table A with every row from table B, no questions asked, no common key needed.

Natural joins are like the more refined and selective cousin who only combines rows from multiple tables if they have something in common (i.e., common columns/keys).

While cross join doesn't discriminate and will create a massive table if given the chance, natural join is more selective and only returns a table with the number of rows equal to the number of matching rows in the input tables. So, choose your JOIN wisely!

SQL Question 4: Pinterest's Popular Boards

Pinterest users can create and share content in the form of personal "boards". Each board is categorized under a specific theme, such as "Home Decor" or "Travel".

Write a SQL query to find the top 3 most popular boards in the "Home Decor" category.

Example Input:
Example Input:
2001101'Home Decor'500
2004103'Home Decor'1000
2005102'Home Decor'700


This SQL query joins and tables on , and filters out boards that are not in the 'Home Decor' category. It then orders the output by in descending order, and finally limits the output to just the top 3 board.

Old Lady Who Likes Pinterest

SQL QUESTION 5: How can you determine which records in one table are not present in another?

To find records in one table that aren't in another, you can use a and check for values in the right-side table.

Here's an example using two tables, Pinterest employees and Pinterest managers:

This query returns all rows from Pinterest employees where there is no matching row in managers based on the column.

You can also use the operator in PostgreSQL and Microsoft SQL Server to return the records that are in the first table but not in the second. Here is an example:

This will return all rows from employees that are not in managers. The operator works by returning the rows that are returned by the first query, but not by the second.

Note that isn't supported by all DBMS systems, like in MySQL and Oracle (but have no fear, since you can use the operator to achieve a similar result).

SQL Question 6: Filter Pinterest Users Who Like Cooking

As a data analyst for Pinterest, we are interested in getting insight into our users' activity and interests. For this reason, we would like to write a SQL query which lists all users who have pinned at least 5 objects in "Cooking" category and have not pinned any objects in "Gardening" category within the past 30 days.

Pinterest Cooking SQL Interview Question

Assume we have a 'users' table and 'pins' table with the following fields and data:

Example Input:
Example Input:


This query first filters users who have pinned at least 5 objects in 'Cooking' category in the subquery named . The main query then checks if these users have pinned any object in 'Gardening' category within the last 30 days. If not, those users will be included in the final output.

SQL QUESTION 7: Can you explain what a cross-join is and the purpose of using them?

A cross-join, also known as a cartesian join, is a JOIN that produces the cross-product of two tables. In a cross-join, each row from the first table is matched 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.

Let's say you were building a Machine Learning model that attempts to score the probability of a customer purchasing a Pinterest product. Before working in Pandas and Tensorflow, you might want to do some Exploratory Data Analysis (EDA) in SQL, and generate all pairs of customers and Pinterest products.

Here's a cross-join query you could run:

Cross-joins are useful for generating all possible combinations, but they can also create huge tables if you're not careful. For instance, if you had 10,000 potential customers and Pinterest had 500 different product SKUs, the resulting cross-join would have 5 million rows!

SQL Question 8: Average Number of Pins per board for a User

For Pinterest, we could consider a situation where we want to find the average number of pins places on each board by a specific user.

Given a table representing pins created by users and a table representing boards created by users, find out the average number of pins per board for a specific user.

Example Input:
201123106/08/2024 00:00:00
231123106/10/2024 00:00:00
456123206/18/2024 00:00:00
789123207/26/2024 00:00:00
567123307/05/2024 00:00:00
Example Input:


This SQL block joins the and tables where the user_id is 123, groups the data by user and board, and calculates the count of pins for each board. It then finds the average count of pins across all boards for the user. It will provide the average number of pins per board for the user with id 123.

SQL Question 9: Analyze the Click Through Rates for Pinterest

You are a data analyst at Pinterest. The marketing department has asked you to analyze their digital ads. Specifically, they are interested in the click-through rates for each ad.

Here is what the data looks like:


Compute the Click Through Rate (CTR) for each ad for the month of July 2024. CTR is calculated by dividing the total number of clicks that an ad receives by the total number of views, then multiplying by 100.


Consider the following SQL query:

In this query, we join the table with the table on and to get the total number of clicks and views per ad. We filter out any clicks that did not occur in July 2024. Finally, we compute the CTR by dividing the count of clicks by the count of views and multiply by 100 for the percentage.

To learn more about Pinter

SQL QUESTION 10: What sets the 'BETWEEN' and 'IN' operators apart?

is used to select rows that match a range of values, whereas the operator checks for values in a specified list of values.

For example, say you were a Data Analyst at Pinterest and had a table of advertising campaign data.

To find campaigns with between 500and500 and 10k in spend, you could use BETWEEN`:

To find ad campaigns that were run on Facebook and Google's Display Network, you could use :

To practice a similar problem about calculating rates, solve this SQL interview question from TikTok on DataLemur's interactive coding environment: TikTok SQL question

SQL Question 11: Filtering User Interactions on Pinterest Boards

Pinterest maintains a vast database of users, boards, and pin ideas. For this SQL question, we want to understand the user interactions in the context of our broad topics available on Pinterest.

Your task is to write a SQL query that filters the user interaction records for the boards that are related to "Food" and "Diy" topics. Specifically, find all user interactions where the board name starts with "Food" or "Diy."

Example Input:


This SQL query filters the interactions and returns all records where the column starts with either "Food" or "Diy". The '%' in the LIKE statement acts as a wildcard and matches any sequence of characters that follow the specified string.

How To Prepare for the Pinterest SQL Interview

The best way to prepare for a Pinterest SQL interview is to practice, practice, practice. In addition to solving the above Pinterest SQL interview questions, you should also solve the 200+ SQL coding questions which come from companies like Netflix, Google, and Amazon.

DataLemur Question Bank

Each exercise has hints to guide you, fully explained answers along with a discussion board to see how others solved it and crucially, there's an online SQL coding environment so you can right online code up your SQL query and have it checked.

To prep for the Pinterest SQL interview you can also solve SQL problems from other tech companies like:

But if your SQL foundations are weak, forget about jumping right into solving questions – improve your SQL foundations with this free SQL for Data Analytics course.

Interactive SQL tutorial

This tutorial covers SQL concepts such as aggregate functions and Union vs. UNION ALL – both of which show up often during Pinterest interviews.

Pinterest Data Science Interview Tips

What Do Pinterest Data Science Interviews Cover?

For the Pinterest Data Science Interview, beyond writing SQL queries, the other types of questions which are covered:

How To Prepare for Pinterest Data Science Interviews?

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

  • 201 Interview Questions from tech companies like Netflix, Google, & Airbnb
  • A Refresher covering Stats, ML, & Data Case Studies
  • Amazing Reviews (900+ reviews, 4.5-star rating)

Acing Data Science Interview