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?
As a data analyst at MediaTek, you are asked to analyze the feedback received for various products over the time. From the 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 table, where:
review_id | user_id | submit_date | product_id | stars |
---|---|---|---|---|
6171 | 123 | 2022-06-08 | 50001 | 4 |
7802 | 265 | 2022-06-10 | 69852 | 4 |
5293 | 362 | 2022-06-18 | 50001 | 3 |
6352 | 192 | 2022-07-26 | 69852 | 3 |
4517 | 981 | 2022-07-05 | 69852 | 2 |
Your result should return a table with columns:
mth | product | avg_stars |
---|---|---|
6 | 50001 | 3.50 |
6 | 69852 | 4.00 |
7 | 69852 | 2.50 |
This query uses the to group the reviews by month. Then it uses the to calculate the monthly average rating for each product. The clause groups the data by month and product id, and finally 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 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:
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_id | customer_id | product_id | region_id | sales_date | sales_amount |
---|---|---|---|---|---|
1 | 1001 | 2001 | 1 | 01/02/2022 00:00:00 | 200 |
2 | 1002 | 2002 | 2 | 01/05/2022 00:00:00 | 300 |
3 | 1001 | 2001 | 1 | 02/10/2022 00:00:00 | 250 |
4 | 1002 | 2002 | 1 | 02/05/2022 00:00:00 | 350 |
5 | 1001 | 2001 | 2 | 03/08/2022 00:00:00 | 450 |
product_id | product_name | product_price |
---|---|---|
2001 | Chipset A | 50 |
2002 | Chipset B | 70 |
region_id | region_name |
---|---|
1 | North America |
2 | Asia |
This SQL query joins the three tables: , , and . It filters for sales that occurred in the current year in the "North America" region. The function is used to calculate the total sales per product (chipset). The clause is used to group the sales by product. This allows the function to calculate a total for each product.
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.
Given two tables, and , where table contains information about the different ads shown to users and the 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 .
ad_id | date | impressions |
---|---|---|
101 | 12/01/2022 | 1000 |
102 | 12/01/2022 | 2000 |
103 | 12/02/2022 | 1500 |
104 | 12/02/2022 | 2500 |
click_id | ad_id | date | user_id |
---|---|---|---|
201 | 101 | 12/01/2022 | 123 |
202 | 101 | 12/01/2022 | 456 |
203 | 102 | 12/01/2022 | 789 |
204 | 102 | 12/01/2022 | 123 |
205 | 103 | 12/02/2022 | 456 |
206 | 103 | 12/02/2022 | 789 |
207 | 104 | 12/02/2022 | 123 |
208 | 104 | 12/02/2022 | 456 |
Here is the SQL query that would solve for CTR:
This SQL query joins the and tables on and , 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 and and ordered by for easier reading.
To solve a similar problem on DataLemur's free interactive SQL code editor, attempt this Meta SQL interview question:
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 and , say you had a table of MediaTek orders and MediaTek customers.
LEFT JOIN: A 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 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.
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 maintains the product review history and is formatted as follows:
review_id | user_id | submit_date | product_id | rating |
---|---|---|---|---|
1001 | 1035 | 2021-01-25 | 40001 | 4 |
1002 | 2085 | 2021-02-14 | 40001 | 5 |
1003 | 3078 | 2021-02-28 | 40001 | 4 |
1004 | 4089 | 2021-03-08 | 40002 | 3 |
1005 | 5093 | 2021-03-21 | 40002 | 2 |
1006 | 6015 | 2021-04-16 | 40003 | 5 |
1007 | 7019 | 2021-04-27 | 40003 | 4 |
1008 | 8099 | 2021-05-13 | 40003 | 3 |
The table includes columns:
Return a table with Month, Product ID and the Average Rating for that product in that particular month.
Month | Product | Avg Rating |
---|---|---|
01 | 40001 | 4.00 |
02 | 40001 | 4.50 |
03 | 40002 | 2.50 |
04 | 40003 | 4.50 |
05 | 40003 | 3.00 |
Here is the SQL code that would solve the problem:
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.
The keyword removes duplicates from a 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.
table:
name | city |
---|---|
Akash | SF |
Brittany | NYC |
Carlos | NYC |
Diego | Seattle |
Eva | SF |
Faye | Seattle |
You could write a query like this to filter out the repeated cities:
Your result would be:
city |
---|
SF |
NYC |
Seattle |
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 table structure:
In this case, you are expected to filter out the customers that are based in North America and their names include the pattern '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.
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.
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.
This tutorial covers things like handling strings and handling timestamps – both of which pop up frequently during MediaTek SQL interviews.
In addition to SQL interview questions, the other topics tested in the MediaTek Data Science Interview are:
The best way to prepare for MediaTek Data Science interviews is by reading Ace the Data Science Interview. The book's got: