At Wix.com, SQL is typically used for analyzing customer behavior patterns and managing website data for optimized user experience. Unsurprisingly this is why Wix often tests SQL problems in interviews for Data Science, Data Engineering and Data Analytics jobs.
To help you practice for the Wix SQL interview, we've curated 10 Wix.com SQL interview questions – can you solve them?
Wix has a product review system where customers can rate the products they have purchased. The ratings are scored between 1 to 5, with 5 being the best. You are tasked with writing a SQL query that calculates the monthly average rating for each product, sorted by month in ascending order and then by average rating in descending order.
review_id | user_id | review_date | product_id | rating |
---|---|---|---|---|
1001 | 10 | 2022-01-05 | P100 | 5 |
1002 | 20 | 2022-01-10 | P200 | 4 |
1003 | 30 | 2022-01-15 | P100 | 4 |
1004 | 10 | 2022-02-01 | P200 | 3 |
1005 | 20 | 2022-02-05 | P100 | 4 |
1006 | 30 | 2022-02-10 | P200 | 5 |
This SQL command uses PostgreSQL's function to truncate dates to a monthly grain and then groups by the truncated month and product_id. The function then calculates the average rating for each group. The cast is used to eliminate the time part of the dates. The results are then sorted in ascending order by month, and within each month, products are sorted in descending order by their average ratings.
month | product_id | average_rating |
---|---|---|
2022-01-01 | P100 | 4.5 |
2022-01-01 | P200 | 4.0 |
2022-02-01 | P200 | 4.0 |
2022-02-01 | P100 | 4.0 |
p.s. Window functions show up pretty frequently during SQL interviews, so practice the 27+ window function questions on DataLemur
As a data analyst at Wix, you have been asked to analyze the effectiveness of their digital marketing campaign. You have access to two tables which track user interactions with the ads and their subsequent actions on the Wix online store.
The first table 'ad_clicks' logs every time a user clicks on one of Wix's digital ads:
click_id | user_id | click_date | ad_id |
---|---|---|---|
6572 | 153 | 06/18/2022 00:00:00 | 3201 |
4512 | 321 | 06/18/2022 00:00:00 | 6502 |
3534 | 265 | 07/24/2022 00:00:00 | 3201 |
8251 | 884 | 08/12/2022 00:00:00 | 6502 |
7892 | 765 | 08/12/2022 00:00:00 | 3201 |
The second table 'cart_additions' logs every time a user adds a product to their online shopping cart:
addition_id | user_id | addition_date | product_id |
---|---|---|---|
9762 | 153 | 06/18/2022 01:00:00 | 50001 |
2592 | 321 | 06/18/2022 02:30:00 | 69852 |
5431 | 112 | 07/24/2022 15:00:00 | 50001 |
2876 | 765 | 08/12/2022 12:45:00 | 69852 |
6281 | 884 | 08/12/2022 16:00:00 | 50001 |
Your task is to determine the click-through conversion rate, defined as the proportion of ad clicks that resulted in a product being added to a cart. You must produce a result for each ad.
Assuming we only count an 'conversion' if the 'addition_date' follows the 'click_date' for the same 'user_id', but occurs on the same date
The query left joins the 'ad_clicks' table with the 'cart_additions' table on the 'user_id' and the date part of 'click_date' and 'addition_date'. We only consider records where the 'addition_date' is greater than the 'click_date'. The result is grouped by 'ad_id' to calculate the click-through conversion rate per ad - it's the number of unique users who added a product to their cart after clicking an ad, divided by the number of unique users who clicked the ad.
To practice a similar SQL interview question on DataLemur's free online SQL coding environment, solve this Facebook SQL Interview question:
Both and are used to combine the results of two or more SELECT statements into a single result set.
However, only includes one instance of a duplicate, whereas includes duplicates.
Assuming that Wix is a website builder and hosting service, one potential question would be to calculate the maximum number of website visits per day for each website template.
Wix has multiple templates for users to create their website. Naturally, Wix is interested in knowing the popularity of each template, measured by the number of website visits. Compute the maximum number of visits each template has received per day.
visit_id | user_id | visit_date | template_id | visits |
---|---|---|---|---|
6191 | 143 | 06/08/2022 00:00:00 | 40001 | 46 |
7882 | 285 | 06/10/2022 00:00:00 | 79852 | 58 |
5363 | 372 | 06/18/2022 00:00:00 | 40001 | 35 |
6422 | 292 | 07/26/2022 00:00:00 | 79852 | 33 |
4587 | 1861 | 07/05/2022 00:00:00 | 79852 | 27 |
template_id | template_name |
---|---|
40001 | 'Ecommerce Magic' |
79852 | 'Photography Pro' |
date | template | max_visits |
---|---|---|
06/08/2022 | Ecommerce Magic | 46 |
06/10/2022 | Photography Pro | 58 |
06/18/2022 | Ecommerce Magic | 35 |
07/26/2022 | Photography Pro | 33 |
07/05/2022 | Photography Pro | 27 |
This query first performs a JOIN between the 'website_visits' and 'templates' table using template_id as the join condition. It then groups by the date and template_name and computes the maximum number of visits each template receives in a day. The results are ordered by date and template for easy reading and interpretation.
While both types of databases are used to store data (obviously), there's some key differences in how they store and organize data.
Relational databases try to represent the world into neat little tables, with rows and columns. Non-relational (NoSQL) databases use a variety of data models to represent data, including document, key-value, columnar, and graph storage formats.
While the exact types of NoSQL databases is beyond the scope of a Data Analyst and Data Scientist SQL interview at Wix, it's good to know that companies generally choose to use NoSQL databases:
You are a data analyst at Wix, and your marketing team has asked you to pull up a list of all customers using Gmail addresses for their contact information. They are interested in a marketing campaign targeted towards these users and need this data.
customer_id | first_name | last_name | |
---|---|---|---|
1001 | John | Doe | johndoe@gmail.com |
1002 | Jane | Smith | janesmith@gmail.com |
1003 | Tom | Brown | tombrown@yahoo.com |
1004 | Mary | Johnson | maryjohnson@hotmail.com |
1005 | James | Wilson | jameswilson@gmail.com |
Your task is to write a SQL query that only selects records of customers who are using Gmail for their contact email.
This query selects all fields from the table where the field ends with , which is the string pattern for Gmail addresses. It uses the SQL keyword and the wildcard to match any character(s) occurring before in the field.
customer_id | first_name | last_name | |
---|---|---|---|
1001 | John | Doe | johndoe@gmail.com |
1002 | Jane | Smith | janesmith@gmail.com |
1005 | James | Wilson | jameswilson@gmail.com |
To discover records in one table that are not present in another, you can utilize a and filter out any values in the right-side table.
For example, say you had a table of Wix customers and a 2nd table of all purchases made with Wix. To find all customers who did not make a purchase, you'd use the following
This query returns all rows from the customers table, along with any matching rows from the purchases table. If there is no matching row in the purchases table, values will be returned for all of the right table's columns. The clause then filters out any rows where the purchases.id column is , leaving only customers who have not made a purchase.
You are given two data tables: customers and purchases. The customers table contains information about all registered customers like customer_id, name, and date_registered. The purchases table includes purchase_id, customer_id, amount, and purchase_date for each purchase made.
Given these tables, write a SQL query to find the top 5 customers who made the most purchases in the last year.
customer_id | name | date_registered |
---|---|---|
1001 | Alice | 06/08/2021 |
1002 | Bob | 06/10/2021 |
1003 | Charlie | 06/18/2021 |
1004 | Dave | 07/26/2021 |
1005 | Eve | 07/05/2021 |
purchase_id | customer_id | amount | purchase_date |
---|---|---|---|
5001 | 1001 | $10.00 | 06/08/2022 |
5002 | 1001 | $12.00 | 06/10/2022 |
5003 | 1002 | $8.50 | 06/18/2022 |
5004 | 1003 | $30.00 | 07/26/2022 |
5005 | 1001 | $20.00 | 07/05/2022 |
In the above query, we first join the two tables on customer_id. Then, we only consider the purchases made in the last year using the WHERE clause filtering on purchase_date. We group the combined data by customer name and count the number of purchases for each user. The results are ordered in descending order to get the top customers, and limit is used to get only the top 5.
Because joins come up so often during SQL interviews, practice an interactive Spotify JOIN SQL question:
The eCommerce team at Wix uses two types of discounts on products: a fixed discount that is subtracted from the product's price and a percentage discount that is multiplied by the product's price. The discounts are applied cumulatively, and the fixed discount is applied before the percentage discount.
Given the following table of purchases, write a PostgreSQL query that calculates the total gross revenue (the total amount before any discounts), the total discount amount (fixed + percentage), and the net revenue (gross revenue - total discount) for each product.
purchase_id | product_id | price | fixed_discount | percentage_discount |
---|---|---|---|---|
1 | 50001 | 100 | 20 | 0.05 |
2 | 50001 | 100 | 10 | 0.10 |
3 | 69852 | 200 | 0 | 0.10 |
4 | 50001 | 100 | 30 | 0.10 |
5 | 69852 | 200 | 50 | 0.05 |
product_id | gross_revenue | total_discount | net_revenue |
---|---|---|---|
50001 | 300 | 70 | 230 |
69852 | 400 | 70 | 330 |
The result of this query is the gross revenue, total discount, and net revenue from each product. The ROUND function is used to limit the decimal points to two, keeping the values in currency format. The ABS function is not used in this problem, but could easily be included to ensure that all calcualted values are positive. The Arithmetic operations are utilized heavily to perform calculations necessary for the business to gauge product performance and adjust discount strategies if needed.
To practice a very similar question try this interactive Amazon Highest-Grossing Items Question which is similar for calculating total gross revenue or this CVS Health Pharmacy Analytics (Part 1) Question which is similar for product profit calculation.
To clarify the distinction between a primary key and a foreign key, let's examine employee data from Wix's HR database:
:
+------------+------------+------------+------------+ | employee_id| first_name | last_name | manager_id | +------------+------------+------------+------------+ | 1 | Aubrey | Graham | 3 | | 2 | Marshal | Mathers | 3 | | 3 | Dwayne | Carter | 4 | | 4 | Shawn | Carter | | +------------+------------+------------+------------+
In this table, serves as the primary key. It uniquely identifies each employee and cannot be null.
functions as a foreign key, linking to the of the employee's manager. This establishes a relationship between Wix employees and their managers, allowing for easy querying to find an employee's manager or see which employees report to a specific manager.
The table may also have multiple foreign keys that reference primary keys in other tables. For example, and foreign keys could be used to connect each employee to their respective department and location.
The best way to prepare for a Wix SQL interview is to practice, practice, practice. Beyond just solving the above Wix SQL interview questions, you should also solve the 200+ SQL questions on DataLemur which come from companies like Google, Uber, and Microsoft.
Each exercise has multiple hints, full answers and best of all, there is an online SQL coding environment so you can instantly run your SQL query answer and have it checked.
To prep for the Wix SQL interview you can also be useful to solve SQL problems from other tech companies like:
In case your SQL coding skills are weak, don't worry about jumping right into solving questions – go learn SQL with this SQL tutorial for Data Analytics.
This tutorial covers topics including how window functions work and math functions like CEIL()/FLOOR() – both of which pop up routinely in Wix SQL interviews.
In addition to SQL interview questions, the other topics covered in the Wix Data Science Interview are:
The best way to prepare for Wix Data Science interviews is by reading Ace the Data Science Interview. The book's got: