At Acer, SQL is typically used for analyzing customer usage patterns across their tech products and optimizing supply chain logistics based on market data insights. That's why Acer almost always evaluates jobseekers on SQL coding questions during interviews for Data Science and Data Engineering positions.
To help you prepare for the Acer SQL interview, this blog covers 9 Acer SQL interview questions – how many can you solve?
Given the dataset, can you calculate the average rating () per product () per month of year ()? Assume that is in 'YYYY-MM-DD' format.
Use this sample data in the table to construct your answer:
review_id | user_id | submit_date | product_id | stars |
---|---|---|---|---|
1 | 1001 | 2022-06-01 | 10001 | 5 |
2 | 1002 | 2022-06-03 | 10001 | 3 |
3 | 1003 | 2022-06-05 | 10002 | 2 |
4 | 1004 | 2022-06-07 | 10001 | 3 |
5 | 1005 | 2022-07-01 | 10002 | 5 |
6 | 1006 | 2022-07-03 | 10002 | 4 |
7 | 1007 | 2022-07-05 | 10002 | 3 |
8 | 1008 | 2022-07-07 | 10002 | 5 |
A possible query to answer this question is as follows:
This query extracts the month from the using the function. It then groups by the extracted month and to calculate the , or average number of stars, per product per month. Finally, it orders the output by and the month for easier interpretability.
Expected output:
mth | product | avg_stars |
---|---|---|
6 | 10001 | 3.67 |
6 | 10002 | 2.00 |
7 | 10002 | 4.25 |
For more window function practice, try this Uber SQL problem within DataLemur's interactive SQL code editor:
As a data analyst at Acer, consider you have two tables: and . The table contains information about the products Acer sells, and the table contains sales data for these products. You are tasked to find out the total sales volume for each product category for the current year.
product_id | name | category |
---|---|---|
P1001 | Laptop | Computing |
P1002 | Desktop | Computing |
P1003 | Monitor | Peripherals |
P1004 | Printer | Peripherals |
P1005 | Tablet | Mobile |
sale_id | product_id | sale_date | quantity |
---|---|---|---|
S2001 | P1001 | 01/12/2021 | 5 |
S2002 | P1001 | 02/24/2021 | 3 |
S2003 | P1003 | 03/15/2021 | 4 |
S2004 | P1004 | 04/18/2021 | 2 |
S2005 | P1005 | 12/30/2021 | 6 |
This PostgreSQL query joins the and tables on . It uses the function to filter out the sales data for the current year. The clause groups the results by product , and the function gives the total sales volume for each category.
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 worry about knowing which DBMS supports which exact commands since Acer interviewers aren't trying to trip you up on memorizing SQL syntax).
For a tangible example of in PostgreSQL, suppose you were doing an HR Analytics project for Acer, and had access to Acer'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:
In a typical business setting, we'd often want to know customer activities and trends. In this case, Acer wants to analyze customers based on purchase date and specific laptop models.
Assume you are given a 'customers' table and a 'purchases' table. The 'customers' table contains customer records, and the 'purchases' table contains purchase records.
Now, Acer wants to identify all customers who have purchased the laptop model "Predator 17X" during the year 2021.
Please write a SQL query to retrieve all the relevant customer records.
customer_id | first_name | last_name | |
---|---|---|---|
101 | John | Doe | johndoe@gmail.com |
102 | Jane | Smith | janesmith@gmail.com |
103 | Robert | Johnson | robertjohnson@gmail.com |
104 | Michael | Williams | michaelwilliams@gmail.com |
purchase_id | customer_id | laptop_model | purchase_date |
---|---|---|---|
1 | 101 | Aspire 5 | 2020-12-01 |
2 | 102 | Predator 17X | 2021-03-15 |
3 | 103 | Aspire 3 | 2021-11-10 |
4 | 104 | Predator 17X | 2021-07-25 |
5 | 102 | Aspire 7 | 2021-06-20 |
customer_id | first_name | last_name | |
---|---|---|---|
102 | Jane | Smith | janesmith@gmail.com |
104 | Michael | Williams | michaelwilliams@gmail.com |
Here is a PostgreSQL solution for the problem:
In this query, we first make a JOIN operation on 'customers' and 'purchases' tables, then filtering the data such that the laptop model is "Predator 17X" and the purchase year is 2021.
The EXTRACT function is used to pull out the Year part from the 'purchase_date' column. If it matches 2021, the record is included in the results.
Joins in SQL allow you to combine data from different tables based on a shared key or set of keys.
Four JOIN types are available in SQL. For an example of each one, say you had sales data exported from Acer's Salesforce CRM stored in a PostgreSQL database, and had access to two tables: and .
Acer Inc is a multinational hardware and electronics corporation that sells different types of computer hardware products like desktops, laptops, tablets, servers, storage devices, Virtual Reality devices, displays, smartphones and peripherals, and also provides e-business services to businesses, government and education. Each product has a unique product_id and their sales are logged in the 'sales' table. Assume each entry in the 'sales' table represents a single unit sale of that product. Write an SQL query which calculates the total sales of each Acer product.
sale_id | sale_date | product_id | price |
---|---|---|---|
1256 | 2022-07-01 00:00:00 | 78452 | 1100 |
4528 | 2022-07-15 00:00:00 | 50101 | 1350 |
7981 | 2022-07-22 00:00:00 | 78452 | 1100 |
6182 | 2022-08-01 00:00:00 | 69856 | 900 |
9192 | 2022-08-12 00:00:00 | 50101 | 1350 |
7457 | 2022-08-18 00:00:00 | 69856 | 900 |
This query will give the total sales of each product. is used to aggregate the sales table by , enabling calculation of sum of for each . The function calculates the sum of all values in for each group. The result is a list of unique s alongside the total revenue generated by each product.
A foreign key is a column or group of columns in a table that refers to the primary key in another table. The foreign key constraint helps maintain referential integrity between the two tables. The table with the foreign key is called the child table, while the table with the candidate key is called the parent or referenced table.
For example, consider a database with two tables: and customer_idcustomer_idcustomer_id` column in Acer customers table.
Acer is looking to better understand its product ratings. Your task is to write a SQL query to calculate the monthly average product rating and rating deviation for each Acer product. Additionally, since Acer often releases new software updates, the company is interested in the changes in ratings post-update. For this use case, you need to compute the average rating and rating deviation three days after each software update.
Assume you have two tables -- 'reviews' and 'updates' -- with the following structure and example data:
review_id | user_id | submit_date | product_id | rating |
---|---|---|---|---|
1 | 101 | 2022-01-01 | 1001 | 4 |
2 | 102 | 2022-01-02 | 1002 | 3 |
3 | 103 | 2022-01-03 | 1003 | 5 |
4 | 104 | 2022-01-04 | 1001 | 3 |
5 | 105 | 2022-02-01 | 1001 | 5 |
update_id | update_date | product_id |
---|---|---|
1 | 2022-01-02 | 1001 |
2 | 2022-01-04 | 1003 |
Here is a SQL (PostgreSQL) solution to the problem:
This SQL query calculates the average rating and rating deviation for every product, for every month, after any software update within a three-day window. The AVG() function is used to calculate the average rating, and the SQRT() and POWER() functions are used to calculate the rating deviation. The query uses the INNER JOIN clause to only consider reviews for products that had a software update and were reviewed within three days of the update.
As an analyst at Acer, one of your responsibilities is tracking sales trends for different product models. The company is interested in understanding the month-to-month sales in quantity for different laptop models. Build a SQL query that provides a month-over-month sales quantity report of Acer's laptop models for the year 2022.
Please use the following input data for your solution:
sale_id | sale_date | product_id | quantity |
---|---|---|---|
1 | 01/05/2022 | L101 | 3 |
2 | 01/12/2022 | L102 | 5 |
3 | 01/18/2022 | L102 | 2 |
4 | 02/04/2022 | L101 | 6 |
5 | 02/21/2022 | L102 | 4 |
6 | 03/09/2022 | L101 | 5 |
7 | 03/15/2022 | L102 | 3 |
8 | 03/20/2022 | L101 | 1 |
The output should list each model, each month in the year 2022 and how many that model sold that month:
month | product_id | total_quantity |
---|---|---|
1 | L101 | 3 |
1 | L102 | 7 |
2 | L101 | 6 |
2 | L102 | 4 |
3 | L101 | 6 |
3 | L102 | 3 |
This SQL query extracts the month from the date of the sales, groups the data by the month and the product_id and then sums up the quantity of laptops sold for each model each month. The result is ordered by month and product_id to easily view the sales trend for each laptop over the months in 2022.
The key to acing a Acer SQL interview is to practice, practice, and then practice some more! In addition to solving the earlier Acer SQL interview questions, you should also solve the 200+ tricky sql questions on DataLemur which come from companies like Netflix, Google, and Amazon.
Each SQL question has multiple hints, step-by-step solutions and most importantly, there is an interactive SQL code editor so you can instantly run your SQL query answer and have it graded.
To prep for the Acer SQL interview it is also useful to solve SQL questions from other tech companies like:
In case your SQL foundations are weak, forget about diving straight into solving questions – refresh your SQL knowledge with this SQL interview tutorial.
This tutorial covers things like LEAD/LAG and creating summary stats with GROUP BY – both of which pop up routinely during Acer interviews.
In addition to SQL interview questions, the other topics to practice for the Acer Data Science Interview are:
The best way to prepare for Acer Data Science interviews is by reading Ace the Data Science Interview. The book's got: