At Zeta Global, SQL is often used for analyzing customer behavior trends and creating advertising customer segments which marketers can then target. That's why Zeta Global almost always evaluates jobseekers on SQL coding questions in interviews for Data Analytics, Data Science, and Data Engineering jobs.
Thus, to help you prepare for the Zeta Global SQL interview, we've curated 10 Zeta Global SQL interview questions – able to answer them all?
Zeta Global, being a data-driven marketing technology company, cares deeply about the behavior of its active users, particularly the highly engaged ones. One of the crucial tasks for the company is to identify "whale users". These users are ones who have an exceptionally high website visit frequency, as they utilize the services provided frequently and have proven to be a significant source of revenue for the business.
You are given a database of user web activity with two tables: and .
user_id | signup_date | active_status |
---|---|---|
111 | 2022-01-03 | Active |
222 | 2022-02-12 | Inactive |
333 | 2022-03-17 | Active |
444 | 2022-04-27 | Active |
555 | 2022-05-07 | Active |
web_id | user_id | visit_date | page_views |
---|---|---|---|
9876 | 111 | 2022-07-03 | 5 |
6543 | 222 | 2022-07-03 | 7 |
3210 | 333 | 2022-07-03 | 10 |
1357 | 444 | 2022-07-04 | 8 |
2468 | 555 | 2022-07-04 | 9 |
Write a SQL query to identify the "whale users" – the users who have visited the website more than 5 times in the last 7 days. Return a list of user_ids and number of visits.
This query identifies the "whale users" by filtering for the users who visited the website more than 5 times in the last 7 days. The result includes the user_id and the number of website visits. The list is sorted in descending order of the number of visits.
To practice a related customer analytics question on DataLemur's free online SQL coding environment, try this Microsoft Azure Cloud SQL Interview Question:
At Zeta Global, imagine you are a data analyst who is asked to help the marketing team understand the company's marketing expenditure per client per quarter. The database contains a table named with columns , , . You have to write an SQL query to calculate the total marketing spend for each client per quarter. The quarter should be derived from the .
client_id | spend_date | marketing_spend |
---|---|---|
101 | 2021-01-15 | 50000 |
101 | 2021-02-20 | 45000 |
102 | 2021-01-10 | 37700 |
101 | 2021-04-12 | 35700 |
102 | 2021-03-04 | 55000 |
102 | 2021-06-22 | 59900 |
101 | 2021-07-18 | 66200 |
The output should include , and , sorted by and .
client_id | quarter | total_spend |
---|---|---|
101 | Q1 | 95000 |
101 | Q2 | 35700 |
101 | Q3 | 66200 |
102 | Q1 | 92700 |
102 | Q2 | 59900 |
In PostgreSQL, you can extract the quarter from a date with and perform a group by on this expression along with client_id. Here is how you can solve this problem:
This query first groups the rows by and and then sums the for each group. The resulting total spend for each client in each quarter is displayed and sorted by and .
Pro Tip: Window functions are a popular SQL interview topic, so practice all the window function problems on DataLemur
Views are a lot like virtual tables, where you can take a base table and customize it (such as by hiding some data from non-admin users, or removing some random columns/rows based on business requirements).
Here's the PostgreSQL syntax for creating a view based on data in the table:
As a data analyst at Zeta Global, your duty includes generating insights from the customer database. You are tasked with creating a list of active customers, who are located in New York and have had any form of interaction (like product purchase, query, or complaint) within the last 3 months for a marketing campaign.
For the purpose of this task, active customers are ones who made a purchase within the last year. Use the , , and tables.
customer_id | first_name | last_name | last_purchase_date |
---|---|---|---|
101 | John | Doe | 2022-01-10 |
102 | Jane | Doe | 2021-05-01 |
103 | Bob | Alice | 2022-07-30 |
104 | Alice | Johnson | 2022-06-22 |
105 | Charlie | Harper | 2021-12-15 |
location_id | customer_id | city | state |
---|---|---|---|
201 | 101 | New York | NY |
202 | 102 | Los Angeles | CA |
203 | 103 | New York | NY |
204 | 104 | Houston | TX |
205 | 105 | New York | NY |
interaction_id | customer_id | interaction_date | interaction_type |
---|---|---|---|
401 | 101 | 2022-08-01 | Purchase |
402 | 102 | 2022-08-01 | Query |
403 | 103 | 2022-09-01 | Complaint |
404 | 104 | 2022-05-01 | Purchase |
405 | 105 | 2022-01-01 | Complaint |
This SQL query first establishes links between customers, their locations, and their interactions. Then it filters customers based on the criteria: customers that made a purchase within the last year, had an interaction within the last 3 months, and are located in New York.
A foreign key is a field in a database table that links to the primary key of another table, establishing a connection between the two tables. For example, let's analyze Zeta Global's Google Ads campaigns data:
:
+------------+------------+------------+------------+ | ad_id | campaign_id| keyword | click_count| +------------+------------+------------+------------+ | 1 | 201 | Zeta Global reviews | 120 | | 2 | 202 | Zeta Global pricing | 150 | | 3 | 101 | buy Zeta Global | 65 | | 4 | 101 | Zeta Global alternatives | 135 | +------------+------------+------------+------------+
is a foreign key that connects to the of the corresponding Google Ads campaign. This establishes a relationship between the ads and their campaigns, enabling easy querying to find which ads belong to a specific campaign or which campaigns a specific ad belongs to.
The table may also have multiple foreign keys that reference primary keys in other tables. For example, and foreign keys could be used to link each ad to its ad group and the Google Ads account that the campaigns belong to, respectively.
Zeta Global, a digital marketing company, wants to assess the performance of its various digital advertisement campaigns. They are interested in understanding the click-through conversion rates of their advertisements. Conversion, in this case, is defined by the action of a user viewing an advertised product and then adding that product to their cart.
You are provided with two tables and . The table records every instance a user clicks on an advertisement to view a product. The table logs every instance a user adds a product into their cart after viewing it.
click_id | user_id | ad_id | product_id | click_time |
---|---|---|---|---|
1011 | 567 | 201 | 50001 | 06/18/2022 09:00:00 |
1012 | 890 | 202 | 69852 | 06/19/2022 10:30:00 |
1013 | 456 | 201 | 50001 | 06/20/2022 21:00:00 |
1014 | 890 | 202 | 50001 | 06/21/2022 08:25:00 |
1015 | 123 | 203 | 69852 | 06/23/2022 12:00:00 |
add_id | user_id | product_id | add_time |
---|---|---|---|
5011 | 567 | 50001 | 06/18/2022 09:05:00 |
5012 | 890 | 69852 | 06/19/2022 10:31:00 |
5013 | 456 | 50001 | 06/20/2022 21:05:00 |
5014 | 760 | 50001 | 06/22/2022 15:45:00 |
5015 | 123 | 69852 | 06/24/2022 10:20:00 |
Write a SQL query that calculates the click-through conversion rate for each product. This is calculated as the number of times a clicked product was added to the cart, divided by the total number of clicks the product received.
This SQL query starts by joining the table with the table on and where the click time is is lesser or equal to the cart addition time. This effectively pairs each click of a product with the subsequent addition of the same product to the user's cart.
Then, for each product, it calculates the click through conversion rate as the number of instances a product was added to the cart (found in the table) divided by the total number of clicks each product received (found in the table).
To solve a similar problem about calculating rates, try this SQL interview question from TikTok within DataLemur's interactive SQL code editor:
Some similarities between unique and non-unique indexes include:
Some differences between unique and non-unique indexes include:
Zeta Global sells a variety of products, and you are given a database with two tables - one containing product sales and another one containing product details. The "sales" table contains sales date, product_id, and units sold at what price. The "products" table contains product_id and product_name. You are required to write a query that returns the total revenue generated from each product.
Below are the structure and some data from the "sales" and "products" tables:
sale_id | sale_date | product_id | units_sold | price_per_unit |
---|---|---|---|---|
101 | 01/01/2021 | 1 | 10 | 50 |
102 | 01/02/2021 | 2 | 5 | 100 |
103 | 01/03/2021 | 3 | 15 | 200 |
104 | 01/04/2021 | 1 | 20 | 50 |
105 | 01/05/2021 | 2 | 10 | 100 |
106 | 01/06/2021 | 3 | 5 | 200 |
product_id | product_name |
---|---|
1 | Apple |
2 | Banana |
3 | Cherry |
product_name | total_revenue |
---|---|
Apple | 1500 |
Banana | 1500 |
Cherry | 4000 |
You can calculate the total revenue per product by multiplying units_sold with price_per_unit grouped by product_id. You can then join this with the products table to get the product_name.
This query calculates the total revenue (units_sold * price_per_unit) for each product, ordered by revenue in descending order. The JOIN operation combines rows from the sales and products tables based on their shared field, product_id.
Suppose you have been given two tables, "Customers" and "Purchases". The "Customers" table contains information about all the customers of Zeta Global, including their customer_id, first_name, last_name, and registration_date. The "Purchases" table contains details about each purchase, including purchase_id, customer_id (who made the purchase), product_id, purchase_date, and purchase_amount.
Your task is to write an SQL query to get a list of each customer along with their total purchase amount. Include only those customers who registered in 2020 in the output.
customer_id | first_name | last_name | registration_date |
---|---|---|---|
1001 | John | Doe | 02/25/2020 |
1002 | Jane | Deer | 09/14/2020 |
1003 | Sam | Smith | 11/30/2019 |
1004 | Emma | Brown | 08/09/2020 |
1005 | Mike | Davis | 01/16/2021 |
purchase_id | customer_id | product_id | purchase_date | purchase_amount |
---|---|---|---|---|
1 | 1001 | 2001 | 02/26/2020 | 200.0 |
2 | 1001 | 2002 | 12/30/2020 | 150.0 |
3 | 1003 | 2003 | 12/30/2020 | 120.0 |
4 | 1002 | 2001 | 12/20/2020 | 50.0 |
5 | 1002 | 2003 | 12/21/2020 | 130.0 |
Below is an SQL query written for the PostgreSQL database to answer the question:
This SQL query retrieves the customer_id, customer's full_name, and their total purchase_amount by joining the "Customers" and "Purchases" tables on the customer_id, and filtering the data for customers registered in 2020 only. The SUM function is used to get the total purchase_amount of each customer.
Because join questions come up routinely during SQL interviews, try this Snapchat Join SQL question:
Imagine you are organizing a party and have two database tables: one table of people you want to invite and another list of food items you want to serve.
A cross join would be like inviting every person on your list to the party and serving them every food item on the menu, regardless of whether they like the food or not. So, if you had 10 people on your invite list and 5 food items on the menu, you would generate all 50 different combinations of people and food (10 x 5 = 50).
On the other hand, a natural join would be like inviting only the people who like the food items on the menu (based on doing a inner/left/right/outer JOIN on a common key like ).
The best way to prepare for a SQL interview, besides making sure you have strong SQL fundamentals, is to practice a ton of real SQL questions that were asked in recent job interviews. Besides solving the earlier Zeta Global SQL interview questions, you should also solve the 200+ FAANG SQL Questions on DataLemur which come from companies like Microsoft, Google, Amazon, and tech startups.
Each interview question has hints to guide you, step-by-step solutions and crucially, there is an interactive coding environment so you can right in the browser run your SQL query answer and have it checked.
To prep for the Zeta Global SQL interview you can also be useful to practice interview questions from other tech companies like:
In case your SQL coding skills are weak, don't worry about diving straight into solving questions – strengthen your SQL foundations with this SQL tutorial for Data Analytics.
This tutorial covers things like using LIKE and handling date/timestamp data – both of these pop up often in SQL job interviews at Zeta Global.
Besides SQL interview questions, the other types of questions covered in the Zeta Global Data Science Interview are:
The best way to prepare for Zeta Global Data Science interviews is by reading Ace the Data Science Interview. The book's got: