8 MediaTek SQL Interview Questions (Updated 2024)

Updated on

February 14, 2024

At MediaTek, SQL crucial for analyzing customer data to forecast demand, and managing databases to ensure the efficient storage and retrieval of large volumes of data. Unsurprisingly this is why MediaTek LOVES to ask SQL query questions in interviews for Data Analytics, Data Science, and Data Engineering jobs.

So, to help you prepare for the MediaTek SQL interview, here’s 8 MediaTek SQL interview questions – able to answer them all?

8 MediaTek SQL Interview Questions

SQL Question 1: Calculate the Average Product Rating per Month

As a data analyst at MediaTek, you are asked to analyze the feedback received for various products over the time. From the reviews table, you should write a SQL query to find out the average star rating of each product on a monthly basis.

Assume we have below reviews table, where:

  • review_id is the id of the review
  • user_id is the id of the user who submitted the review
  • submit_date is the date when the review was submitted
  • product_id is the id of the product for which the review is given
  • stars is the rating given to the product by the user, on a scale of 1-5
reviews Example Input:
review_iduser_idsubmit_dateproduct_idstars
61711232022-06-08500014
78022652022-06-10698524
52933622022-06-18500013
63521922022-07-26698523
45179812022-07-05698522

Your result should return a table with columns:

  • mth: the month in which the review was submitted.
  • product: the id of the product
  • avg_stars: the average rating of this product in this month round off to two decimal places.
Example Output:
mthproductavg_stars
6500013.50
6698524.00
7698522.50

Answer:

SELECT EXTRACT(MONTH FROM submit_date) as mth, product_id as product, ROUND(AVG(stars), 2) as avg_stars FROM reviews GROUP BY mth, product ORDER BY mth, product;

This query uses the EXTRACT(MONTH FROM submit_date) to group the reviews by month. Then it uses the AVG(stars) to calculate the monthly average rating for each product. The GROUP BY clause groups the data by month and product id, and finally ORDER BY is used to sort the result by month and product id. The entire query is within a round function to round off the average rating to two decimal places. The EXTRACTION of the month is done because we only want to display the Month, not the complete date.

To solve another window function question on DataLemur's free interactive SQL code editor, try this Amazon BI Engineer interview question: Amazon Window Function SQL Interview Problem

SQL Question 2: Chipset Sales Data Analytics

MediaTek, being a global fabless semiconductor company, produces a huge variety of products such as chipsets for different devices. Consider this scenario: MediaTek maintains customer purchase information in one table and product details in another table. In addition to this MediaTek maintains a table for different regions where they sold their products. MediaTek wants to analyze chipset sales data of a specific region and calculate the total sales per chipset for the current year.

Create database tables for this scenario and write a SQL query that shows the total sales per chipset for the region named "North America" for the current year.

sales Example Input:
sales_idcustomer_idproduct_idregion_idsales_datesales_amount
110012001101/02/2022 00:00:00200
210022002201/05/2022 00:00:00300
310012001102/10/2022 00:00:00250
410022002102/05/2022 00:00:00350
510012001203/08/2022 00:00:00450
products Example Input:
product_idproduct_nameproduct_price
2001Chipset A50
2002Chipset B70
regions Example Input:
region_idregion_name
1North America
2Asia

Answer:

SELECT p.product_id, p.product_name, SUM(s.sales_amount) AS total_sales FROM sales AS s JOIN products AS p ON s.product_id = p.product_id JOIN regions AS r ON s.region_id = r.region_id WHERE r.region_name = 'North America' AND EXTRACT(YEAR FROM s.sales_date) = EXTRACT(YEAR FROM NOW()) GROUP BY p.product_id;

This SQL query joins the three tables: sales, products, and regions. It filters for sales that occurred in the current year in the "North America" region. The SUM function is used to calculate the total sales per product (chipset). The GROUP BY clause is used to group the sales by product. This allows the SUM function to calculate a total for each product.

SQL Question 3: Can you give some examples of when denormalization might be a good idea?

Database normalization has several benefits:

  • Reduces Redundancy: Normalization can minimize redundancy by breaking down a larger, general table into smaller, more granular tables. This often reduces the amount of data that needs to be accessed for particular queries, since some duplicated columns can be removed.

  • Improves Data Integrity: Normalization can help to ensure the integrity of the data by minimizing the risk of data inconsistencies and errors. By establishing clear relationships between the tables via primary and foreign keys, and enforcing these constraints, you can have more reliable records and relationships stored in your DB.

  • Improves Performance: Normalization can improve the performance of the database by reducing the amount of data that needs to be stored and accessed in a single table. This results in faster query times and better overall performance.

MediaTek SQL Interview Questions

SQL Question 4: Calculate the Click-Through-Rate for MediaTek Ads

Given two tables, ads and clicks, where ads table contains information about the different ads shown to users and the clicks table contains information about the clicks made by users on different ads, calculate the click-through-rate (CTR) for each ad. The click-through-rate (CTR) is calculated as number of clicks/ number of ad impressions.

ads Sample Input:
ad_iddateimpressions
10112/01/20221000
10212/01/20222000
10312/02/20221500
10412/02/20222500
clicks Sample Input:
click_idad_iddateuser_id
20110112/01/2022123
20210112/01/2022456
20310212/01/2022789
20410212/01/2022123
20510312/02/2022456
20610312/02/2022789
20710412/02/2022123
20810412/02/2022456

Answer:

Here is the SQL query that would solve for CTR:

SELECT a.ad_id, a.date, ((count(c.click_id)::decimal / a.impressions::decimal) * 100) as ctr FROM ads as a JOIN clicks as c ON a.ad_id = c.ad_id AND a.date = c.date GROUP BY a.ad_id, a.date, a.impressions ORDER BY a.ad_id;

This SQL query joins the ads and clicks tables on ad_id and date, counts the number of times each ad was clicked, divides this by the number of times the ad was shown (impressions) and then multiplies by 100 to get the CTR. The result is then grouped by ad_id and date and ordered by ad_id for easier reading.

To solve a similar problem on DataLemur's free interactive SQL code editor, attempt this Meta SQL interview question: Facebook App CTR SQL Interview question

SQL Question 5: What distinguishes a left join from a right join?

A join in SQL combines rows from two or more tables based on a shared column or set of columns. To demonstrate the difference between a LEFT JOIN and RIGHT JOIN, say you had a table of MediaTek orders and MediaTek customers.

LEFT JOIN: A LEFT JOIN retrieves all rows from the left table (in this case, the Orders table) and any matching rows from the right table (the Customers table). If there is no match in the right table, NULL values will be returned for the right table's columns.

RIGHT JOIN: A RIGHT JOIN retrieves all rows from the right table (in this case, the Customers table) and any matching rows from the left table (the Orders table). If there is no match in the left table, NULL values will be returned for the left table's columns.

SQL Question 6: Calculate the Average Ratings for Each MediaTek Product

As a Data Analyst at MediaTek, a leading chip designing company, your manager asks you to compute the average chip rating for each product for every month in the year 2021.

Table named chip_reviews maintains the product review history and is formatted as follows:

chip_reviews Example Input:
review_iduser_idsubmit_dateproduct_idrating
100110352021-01-25400014
100220852021-02-14400015
100330782021-02-28400014
100440892021-03-08400023
100550932021-03-21400022
100660152021-04-16400035
100770192021-04-27400034
100880992021-05-13400033

The chip_reviews table includes columns:

  • review_id: The review's unique identifier
  • user_id: The user's unique identifier who gave the review
  • submit_date: The date when the review was submitted (format is 'YYYY-MM-DD')
  • product_id: The product's unique identifier
  • rating: Rating given by the user to the product (range is from 1 to 5)

Return a table with Month, Product ID and the Average Rating for that product in that particular month.

chip_reviews Example Output:
MonthProductAvg Rating
01400014.00
02400014.50
03400022.50
04400034.50
05400033.00

Answer:

Here is the SQL code that would solve the problem:

SELECT TO_CHAR(submit_date, 'MM') AS Month, product_id AS Product, ROUND(AVG(rating), 2) AS "Avg Rating" FROM chip_reviews WHERE submit_date >= '2021-01-01' AND submit_date < '2022-01-01' GROUP BY Month, Product ORDER BY Month, Product;

This SQL query first filters out the reviews from 2021. The TO_CHAR function is used to extract the 'Month' part from the 'submit_date'. The AVG function is used to calculate average ratings for each 'product_id' for each month. The ROUND function is used to round-off the average rating to 2 decimal places. The results are then ordered by 'Month' and 'Product' in ascending order.

SQL Question 7: What does the SQL keyword DISTINCT do?

The DISTINCT keyword removes duplicates from a SELECT query.

Suppose you had a table of MediaTek customers, and wanted to figure out which cities the customers lived in, but didn't want duplicate results.

mediatek_customers table:

namecity
AkashSF
BrittanyNYC
CarlosNYC
DiegoSeattle
EvaSF
FayeSeattle

You could write a query like this to filter out the repeated cities:

SELECT DISTINCT city FROM mediatek_customers;

Your result would be:

city
SF
NYC
Seattle

SQL Question 8: MediaTek Customer Analysis

Given a list of MediaTek's customer records, can you write a SQL query to find all the customer records who are based in North America and their company name contains the term 'Tech'?

For this problem, consider the following customers table structure:

customers Example Input:
|**customer_id**|**customer_name**|**region**|**creation_date**|
|:----|:----|:----|:----|
|5689|BigTech Labs|North America|08/05/2018|
|4132|FutureTech Inc|North America|12/21/2019|
|9564|Global Innovations|Asia|03/11/2020|
|6812|TechEvolution|Europe|06/25/2016|
|3456|ProgressiveTech|North America|01/15/2017|

In this case, you are expected to filter out the customers that are based in North America and their names include the pattern 'Tech'.

Answer:

SELECT * FROM customers WHERE region LIKE 'North America' AND customer_name LIKE '%Tech%';

This SQL query uses the LIKE keyword to filter customers based in North America and whose names contain the string 'Tech'. The '%' character is a wildcard character that matches any sequence of characters. By placing it before and after 'Tech', the query will match any customer_name where 'Tech' appears anywhere in the string.

Preparing For The MediaTek SQL Interview

Assuming that you've already got basic SQL skills, the next best tip we have to prepare for the MediaTek SQL interview is to solve as many practice SQL interview questions as you can! In addition to solving the above MediaTek SQL interview questions, you should also solve the 200+ tricky sql questions on DataLemur which come from companies like Netflix, Airbnb, and Amazon. DataLemur Question Bank

Each exercise has hints to guide you, detailed solutions and best of all, there is an interactive SQL code editor so you can easily right in the browser your query and have it executed.

To prep for the MediaTek SQL interview you can also be wise to practice SQL questions from other tech companies like:

In case your SQL skills are weak, forget about diving straight into solving questions – go learn SQL with this SQL tutorial for Data Analytics.

DataLemur SQL tutorial

This tutorial covers things like handling strings and handling timestamps – both of which pop up frequently during MediaTek SQL interviews.

MediaTek Data Science Interview Tips

What Do MediaTek Data Science Interviews Cover?

In addition to SQL interview questions, the other topics tested in the MediaTek Data Science Interview are:

MediaTek Data Scientist

How To Prepare for MediaTek Data Science Interviews?

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

  • 201 Interview Questions from tech companies like Google & Microsoft
  • A Crash Course covering Stats, SQL & ML
  • Great Reviews (900+ 5-star reviews on Amazon)

Acing Data Science Interview