At Bandai Namco, SQL does the heavy lifting for analyzing user gameplay data for insights and managing large databases of game, user, and micro-transacton information. Because of this, Bandai Namco almost always asks SQL query questions in interviews for Data Science and Data Engineering positions.
As such, to help you practice for the Bandai Namco SQL interview, we've collected 8 Bandai Namco SQL interview questions – can you solve them?
Bandai Namco is interested in understanding the monthly average ratings for their games on their platform. You have been given the table that contains reviews submitted by users about the games. Each review contains a field representing the number of stars (from 1 to 5) assigned by the user. You need to write a SQL query to calculate the monthly average star rating for each game.
review_id | user_id | submit_date | product_id | stars |
---|---|---|---|---|
6171 | 123 | 06/08/2022 | 50001 | 4 |
7802 | 265 | 06/10/2022 | 69852 | 4 |
5293 | 362 | 06/18/2022 | 50001 | 3 |
6352 | 192 | 07/26/2022 | 69852 | 3 |
4517 | 981 | 07/05/2022 | 69852 | 2 |
mth | product | avg_stars |
---|---|---|
6 | 50001 | 3.50 |
6 | 69852 | 4.00 |
7 | 69852 | 2.50 |
Following is the PostgreSQL query using window function to calculate the monthly average star rating for each product.
This query first selects the month from the using the function, and the , and rating from each review. It then groups the reviews by month and product using the clause in the function, and computes the average stars rating for each group. The result is ordered by month and product.
To solve a similar window function question on DataLemur's free interactive SQL code editor, solve this Google SQL Interview Question:
Bandai Namco, a major game publisher, wants to design a database to track its game sales and player progression data for analytics and player retention purposes. They specifically want to monitor the following data attributes:
Design a database schema for Bandai Namco and write a SQL query that should return the total sales and average player progression level per game, sorted by total sales in descending order.
Note:
game_id | game_name | release_date | genre |
---|---|---|---|
G001 | Tekken 7 | 2017-06-02 | Fighting |
G002 | Dark Souls III | 2016-04-12 | Action RPG |
sale_id | game_id | sold_at_date | unit_price | user_id |
---|---|---|---|---|
S001 | G001 | 2017-07-05 | 59.99 | U001 |
S002 | G002 | 2016-05-10 | 59.99 | U002 |
progress_id | game_id | user_id | level | achieved_at_date |
---|---|---|---|---|
P001 | G001 | U001 | 10 | 2017-08-05 |
P002 | G002 | U002 | 5 | 2016-06-10 |
The above SQL query joins the 'games', 'sales' and 'player_progress' tables based on the 'game_id' and calculates the total sales and average player level for each game. The results are then sorted in descending order of total sales.
Note: interviews at Bandai Namco often aren't trying to test you on a specific flavor of SQL. As such, you don't need to exactly know that is available in PostgreSQL and SQL Server, while MINUS is available in MySQL and Oracle – you just need to know the general concept!
Your answer should mention that the / operator is used to remove to return all rows from the first SELECT statement that are not returned by the second SELECT statement.
Here's a PostgreSQL example of using EXCEPT to find all of Bandai Namco's Facebook video ads with more than 50k views that aren't also being run on YouTube:
If you want to retain duplicates, you can use the EXCEPT ALL operator instead of EXCEPT. The EXCEPT ALL operator will return all rows, including duplicates.
Bandai Namco, being a gaming company, might be interested in knowing the average rating for each of its games across different months. Let's assume that they have a table called . The table has five fields: (an identifier for each review), (an identifier for each user), (the date when the review was submitted), (the identifier for each game) and (the rating given by the user with a value between 1 and 5).
review_id | user_id | submit_date | game_id | stars |
---|---|---|---|---|
6171 | 123 | 06/08/2021 00:00:00 | 50001 | 4 |
7802 | 265 | 06/10/2021 00:00:00 | 69852 | 4 |
5293 | 362 | 06/18/2021 00:00:00 | 50001 | 3 |
6352 | 192 | 07/26/2021 00:00:00 | 69852 | 3 |
4517 | 981 | 07/05/2021 00:00:00 | 69852 | 2 |
mth | game | avg_stars |
---|---|---|
6 | 50001 | 3.50 |
6 | 69852 | 4.00 |
7 | 69852 | 2.50 |
This query extracts the month from the field, groups the rows by this extracted month and the field, and then calculates the average of the field for each group. Finally, it sorts the resulting average ratings in descending order. It will provide Bandai Namco with average ratings of their games across different months.
The CHECK constraint is used to enforce rules on the data in a specific column. If a row is inserted or updated with data that does not follow the CHECK constraint's rule, the operation will fail.
For example, say you had a database that stores ad campaign data from Bandai Namco's Google Analytics account.
Here's what some constraints could look like:
In this example, the constraint is used to ensure that the "budget" and "cost_per_click" fields have positive values. This helps to ensure that the data in the database is valid and makes sense in the context of ad campaigns.
You can also use the constraint to ensure that data meets other specific conditions. For example, you could use a constraint to ensure that the "start_date" is before the "end_date" for each ad campaign.
Bandai Namco, a popular game manufacturer, would like to know how their new games are being received in the market. They are particularly interested in the games which contain the string 'dragon' in their titles, as part of their brand strategy. They wish to get information on which of these games players purchase the most.
Below is a subset of their game purchase transactions:
transaction_id | customer_id | purchase_date | game_id | game_title |
---|---|---|---|---|
9843 | 276 | 04/17/2023 00:00:00 | 982431 | Dragon Ball FighterZ |
6752 | 732 | 04/18/2023 00:00:00 | 584321 | Tales from the Dragon Mountain |
7863 | 561 | 04/20/2023 00:00:00 | 457871 | DIGIMON Story: Dragon Lords |
5462 | 109 | 04/22/2023 00:00:00 | 236523 | DRAGON BALL Z: KAKAROT |
7045 | 838 | 04/24/2023 00:00:00 | 507932 | Dragon Quest XI |
Bandai Namco wants a list of games that contain the string 'dragon' in the title, and the number of purchases for each of these games.
This query filters the table for games that have the string 'dragon' in their title (case insensitive), then groups the filtered results by game title. It counts the number of transactions for each game title, providing a rough estimate of the popularity of each 'dragon'-themed game. The results are then ordered in a descending order of count, to highlight the most popular games first.
Imagine you've got giant AF jigsaw puzzle with thousands of pieces, and each piece represents a piece of data in your database. You've spent hours organizing the puzzle into neat little piles, with each pile representing a table in your database. This process is called normalization, and it's a great way to make your database efficient, flexible, and easy to maintain.
But what if you want to solve the puzzle faster (aka make your queries run faster?)?
That's where denormalization comes in – Denormalization is like the puzzle-solving equivalent of taking a shortcut!
Instead of putting all the pieces in separate piles, you might decide to clone some of the pieces, and then have that one puzzle piece be put into multiple piles. Clearly, we are breaking the rules of physics, but that's just like de-normalization because it breaks the normal rules of normalization (1st, 2nd, 3rd normal forms).
By adding redundant puzzle pieces, it can be easier to find the pieces you need, but it also means that you have to be extra careful when you're moving pieces around or adding new ones (aka INSERT/UPDATE commands become more complex).
On the plus side, denormalization can improve the performance of your database and make it easier to use. On the downside, it can make your database more prone to errors and inconsistencies, and it can be harder to update and maintain. In short, denormalization can be a helpful tool, but it's important to use it wisely!
As a data analyst at Bandai Namco, you are tasked to assess the relationship between the quantity of product sold and the product review ratings. There are two integrated databases at your disposal.
Both databases share a common attribute, , which can be used to join them. Please construct a SQL query to merge both tables and calculate average review ratings per game.
sale_id | game_id | product_id | sale_date | sold_units |
---|---|---|---|---|
781 | 1337 | 50001 | 06/08/2022 00:00:00 | 930 |
782 | 1338 | 69852 | 06/10/2022 00:00:00 | 870 |
783 | 1339 | 62000 | 06/18/2022 00:00:00 | 680 |
784 | 1340 | 50001 | 07/26/2022 00:00:00 | 570 |
785 | 1341 | 69852 | 07/05/2022 00:00:00 | 670 |
review_id | user_id | submit_date | product_id | stars |
---|---|---|---|---|
6171 | 123 | 06/08/2022 00:00:00 | 50001 | 4 |
7802 | 265 | 06/10/2022 00:00:00 | 69852 | 4 |
5293 | 362 | 06/18/2022 00:00:00 | 50001 | 3 |
6352 | 192 | 07/26/2022 00:00:00 | 69852 | 3 |
4517 | 981 | 07/05/2022 00:00:00 | 69852 | 2 |
In this example, the INNER JOIN query links the and table on the field. Then, for each unique product_id, it calculates the average of stars in customer reviews (avg_reviews) and the total number of sold units (total_sold_units).
Since joins come up frequently during SQL interviews, try an interactive SQL join question from Spotify:
The best way to prepare for a Bandai Namco SQL interview is to practice, practice, practice. Beyond just solving the earlier Bandai Namco 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, full answers and crucially, there's an interactive SQL code editor so you can right in the browser run your SQL query answer and have it checked.
To prep for the Bandai Namco SQL interview it is also helpful to practice SQL problems from other tech companies like:
But if your SQL query skills are weak, forget about jumping right into solving questions – go learn SQL with this free SQL for Data Analytics course.
This tutorial covers things like using ORDER BY and using LIKE – both of which pop up routinely during SQL interviews at Bandai Namco.
In addition to SQL interview questions, the other topics to prepare for the Bandai Namco Data Science Interview are:
To prepare for Bandai Namco Data Science interviews read the book Ace the Data Science Interview because it's got: