logo

10 Zeta Global SQL Interview Questions (Updated 2024)

Updated on

March 3, 2024

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?

10 Zeta Global SQL Interview Questions

SQL Question 1: Identifying Whale Users

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 .

Example Input:
user_idsignup_dateactive_status
1112022-01-03Active
2222022-02-12Inactive
3332022-03-17Active
4442022-04-27Active
5552022-05-07Active
Example Input:
web_iduser_idvisit_datepage_views
98761112022-07-035
65432222022-07-037
32103332022-07-0310
13574442022-07-048
24685552022-07-049

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.

Answer:


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: Microsoft SQL Interview Question: Super Cloud Customer

SQL Question 2: Finding the Quarterly Marketing Spend per Client

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 .

Example Input:
client_idspend_datemarketing_spend
1012021-01-1550000
1012021-02-2045000
1022021-01-1037700
1012021-04-1235700
1022021-03-0455000
1022021-06-2259900
1012021-07-1866200

The output should include , and , sorted by and .

Example Output:
client_idquartertotal_spend
101Q195000
101Q235700
101Q366200
102Q192700
102Q259900

Answer:

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

DataLemur SQL Questions

SQL Question 3: What's a database view?

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:


Zeta Global SQL Interview Questions

SQL Question 4: Filter Customers Based on Interaction and Location

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.

Example Input:

customer_idfirst_namelast_namelast_purchase_date
101JohnDoe2022-01-10
102JaneDoe2021-05-01
103BobAlice2022-07-30
104AliceJohnson2022-06-22
105CharlieHarper2021-12-15

Example Input:

location_idcustomer_idcitystate
201101New YorkNY
202102Los AngelesCA
203103New YorkNY
204104HoustonTX
205105New YorkNY

Example Input:

interaction_idcustomer_idinteraction_dateinteraction_type
4011012022-08-01Purchase
4021022022-08-01Query
4031032022-09-01Complaint
4041042022-05-01Purchase
4051052022-01-01Complaint

Answer:


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.

SQL Question 5: In database design, what do foreign keys do?

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.

SQL Question 6: Calculate Click Through Conversion Rates for Zeta Global

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.

Example Input:
click_iduser_idad_idproduct_idclick_time
10115672015000106/18/2022 09:00:00
10128902026985206/19/2022 10:30:00
10134562015000106/20/2022 21:00:00
10148902025000106/21/2022 08:25:00
10151232036985206/23/2022 12:00:00
Example Input:
add_iduser_idproduct_idadd_time
50115675000106/18/2022 09:05:00
50128906985206/19/2022 10:31:00
50134565000106/20/2022 21:05:00
50147605000106/22/2022 15:45:00
50151236985206/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.

Answer:


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: SQL interview question from TikTok

SQL Question 7: Consider unique indexes, and non-unique indexes. What are some similarities and differences?

Some similarities between unique and non-unique indexes include:

  • Both indexes improve the performance of SQL queries by providing a faster way to lookup the desired data.
  • Both indexes use an additional data which requires more storage space which impacts write performance.
  • Both indexes can be created on one or more columns of a table

Some differences between unique and non-unique indexes include:

  • A unique index enforces the uniqueness of the indexed columns, meaning that no duplicate values are allowed in the indexed columns. A non-unique index allows duplicate values in the indexed columns.
  • A unique index can be used to enforce the primary key of a table, but a non-unique index cannot.
  • A unique index can have a maximum of one NULL value in the indexed columns, but a non-unique index can have multiple NULLs

SQL Question 8: Find the Total Revenue Per Product

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:

Example Input:
sale_idsale_dateproduct_idunits_soldprice_per_unit
10101/01/202111050
10201/02/202125100
10301/03/2021315200
10401/04/202112050
10501/05/2021210100
10601/06/202135200
Example Input:
product_idproduct_name
1Apple
2Banana
3Cherry
Example Output:
product_nametotal_revenue
Apple1500
Banana1500
Cherry4000

Answer:

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.

SQL Question 9: Analyzing Customer and Purchase Data

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.

Example Input:

customer_idfirst_namelast_nameregistration_date
1001JohnDoe02/25/2020
1002JaneDeer09/14/2020
1003SamSmith11/30/2019
1004EmmaBrown08/09/2020
1005MikeDavis01/16/2021

Example Input:

purchase_idcustomer_idproduct_idpurchase_datepurchase_amount
11001200102/26/2020200.0
21001200212/30/2020150.0
31003200312/30/2020120.0
41002200112/20/202050.0
51002200312/21/2020130.0

Answer:

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: Snapchat Join SQL question

SQL Question 10: How does a cross join differ from a natural join?

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 ).

Zeta Global SQL Interview Tips

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. DataLemur Questions

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.

SQL tutorial for Data Scientists & Analysts

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.

Zeta Global Data Science Interview Tips

What Do Zeta Global Data Science Interviews Cover?

Besides SQL interview questions, the other types of questions covered in the Zeta Global Data Science Interview are:

  • Probability & Statistics Questions
  • Coding Questions in Python or R
  • Analytics and Product-Metrics Questions
  • ML Modelling Questions
  • Behavioral Interview Questions

Zeta Global Data Scientist

How To Prepare for Zeta Global Data Science Interviews?

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

  • 201 Interview Questions from FAANG tech companies
  • A Refresher on Python, SQL & ML
  • Great Reviews (900+ 5-star reviews on Amazon)

Ace the Data Science Interview by Nick Singh Kevin Huo