logo

11 Nexon SQL Interview Questions (Updated 2024)

Updated on

February 29, 2024

At Nexon, SQL is used all the damn time for analyzing player behavior patterns in games and optimizing database performance for seamless gaming experiences. Unsurprisingly this is why Nexon almost always evaluates jobseekers on SQL questions in interviews for Data Science, Analytics, and & Data Engineering jobs.

To help you prepare for the Nexon SQL interview, we've collected 11 Nexon SQL interview questions – can you solve them?

Nexon SQL Interview

11 Nexon SQL Interview Questions

SQL Question 1: Identify Nexon's Power Users

Nexon is a global leader in online games, with users across the world playing their games for countless hours each day. As a data analyst at Nexon, you are tasked with finding the 'power users' among their players. 'Power users' are defined as users who have spent the most hours playing Nexon's games in the past month. You have access to a 'user_activity' table that logs each gaming session a user embarks on.

Provide a SQL query that will reveal the top 5 power users (user_ids) in the past month (based on the 'session_end' timestamp). Your result should showcase the user_id and total hours spent in descending order.

Sample Data:
session_iduser_idgame_idsession_startsession_end
20111112023-01-01 09:00:002023-01-01 12:30:00
20211112023-01-02 10:00:002023-01-02 11:30:00
20311222023-01-01 08:30:002023-01-01 10:30:00
20411312023-01-03 15:00:002023-01-03 16:00:00
20511222023-01-02 12:00:002023-01-02 13:30:00

Answer:


This query first creates a CTE (Common Table Expression) to calculate total gameplay hours for each user in the last month. Then, it selects the top 5 users with the most gameplay hours. The EXTRACT function is used to get the difference in hours between the session_start and session_end. The CURRENT_DATE - interval '1 month' condition ensures that we only take into account the sessions from the past month.

To practice a related super-user data analysis question on DataLemur's free interactive coding environment, try this recently asked Microsoft SQL interview question: Microsoft SQL Interview Question: Teams Super User

SQL Question 2: Calculate Monthly Average Rating

Using a dataset containing game reviews at Nexon, your task is to write a SQL query in PostgreSQL to calculate the monthly average rating for each product. Given the table which has the following columns: , , , , and (represented as an integer from 1 to 5), write a SQL query to provide an output table with columns for month (), , and average star rating .

Example Input:
review_iduser_idsubmit_dateproduct_idstars
61711232022-06-08500014
78022652022-06-10698524
52933622022-06-18500013
63521922022-07-26698523
45179812022-07-05698522
Example Output:
mthproductavg_stars
6500013.50
6698524.00
7698522.50

Answer:

You would use a SQL query like this:


In the above PostgreSQL query, the function is used to get the month from the . The function is used as an aggregate function to calculate the average of the for each product. The clause is used to group the result-set by month and product. The results are then ordered by month in ascending order and average stars in descending order.

To solve another window function question on DataLemur's free interactive coding environment, try this Google SQL Interview Question: Google SQL Interview Question

SQL Question 3: What sets a cross join apart from a natural join?

Cross join and natural join are like two sides of a coin in the world of SQL.

Cross joins is like the wild and reckless cousin who creates a giant new table by combining every row from table A with every row from table B, no questions asked, no common key needed.

Natural joins are like the more refined and selective cousin who only combines rows from multiple tables if they have something in common (i.e., common columns/keys).

While cross join doesn't discriminate and will create a massive table if given the chance, natural join is more selective and only returns a table with the number of rows equal to the number of matching rows in the input tables. So, choose your JOIN wisely!

Nexon SQL Interview Questions Sure, here's an interview question tailored towards a gaming company like Nexon, which could be facing challenges such as understanding player gaming habits so as to improve retention.

SQL Question 4: Analyzing player gaming habits

As a data analyst at Nexon, you are tasked to analyze the gaming habits of players. You want to find the average duration of daily gameplay for each game Nexon offers during the past month.

You have two tables -

Example Input:

session_idplayer_idgame_idstart_timeend_time
1235981232502022-07-01 10:00:002022-07-01 13:00:00
1236182952512022-07-01 15:00:002022-07-01 16:00:00
1237981232502022-07-02 10:30:002022-07-02 12:30:00
1238182952502022-07-02 20:00:002022-07-02 22:00:00
1239574122522022-07-03 09:00:002022-07-03 13:00:00

Example Input:

game_idgame_title
250Maple Story
251Dungeon Fighter
252Mabinogi

Example Output:

game_titleaverage_playtime
Maple Story2.50
Dungeon Fighter1.00
Mabinogi4.00

Answer:

Please note that the output's average playtime is in 'hours' for ease of understanding.


This query first calculates the duration of each game session in hours by subtracting the start_time from the end_time and converting the interval to hours. It then averages this duration for each game over the past month. The results are grouped by game_name using a join on the game_id between the two tables.

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

A join in SQL allows you to retrieve data from multiple tables and combine it into a single set of results.

To demonstrate the difference between left vs. right join, imagine you had two database tables, an advertising campaigns table which had information on Google Ads keywords and how much was bid for each keyword, and a sales table, which has data on how many products were sold and which Google Ads keyword drove that sale.

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

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

SQL Question 6: Filter Customers by Purchases and Revenue

Nexon Corporation is analyzing game purchases and revenues from different customers. The campaign is targeted towards customers who made at least three purchases or have spent over 100,000 in total revenue, regardless of the number of purchases. Given the customer records, write a query to filter and list the customers.

Customers Table:

customer_idname
1John Doe
2Jane Smith
3Robert Johnson
4Jennifer Williams
5Linda Brown

Purchases Table:

purchase_idcustomer_idpurchase_dateproduct_idamount_spent
101106/08/202220120000
102106/09/202220205000
103106/09/202220315000
104206/10/202220478000
105206/11/202220525000
106306/10/202220650000
107406/12/202220730000
108506/13/2022208120000

Answer:


This query first makes a sub-query on table to find the number of purchases() and total revenue() for each customer. It then performs operation on and the sub-query on , and applies clause to filter out customers who made at least three purchases or have total revenue over 100,000. The result of the query is the list of these customers' names.

SQL Question 7: Can you provide an example of two entities that have a one-to-one relationship, and another example of a one-to-many relationship?

In database schema design, a one-to-one relationship is when each entity is associated with only one instance of the other. For instance, a US citizen's relationship with their social-security number (SSN) is one-to-one because each citizen can only have one SSN, and each SSN belongs to one person.

A one-to-many relationship, on the other hand, is when one entity can be associated with multiple instances of the other entity. An example of this is the relationship between a person and their email addresses - one person can have multiple email addresses, but each email address only belongs to one person.

SQL Question 8: Find Customers with Emails from Specific Domains

Nexon maintains a customer records database. They are specifically interested in identifying customers who have their email addresses registered with certain internet service providers (ISPs). Write a SQL query to find all Nexon customers whose email addresses end with "@isp.com" or "@hosting.com".

Sample tables:

Example Input:
CustomerIDFirstNameLastNameEmail
1001JohnDoejohn.doe@net.com
1002JaneSmithjane.smith@isp.com
1003MikeJohnsonmike.johnson@hosting.com
1004EmmaBrownemma.brown@misc.com
1005TomAndersontom.anderson@isp.com
Example Output:
CustomerIDFirstNameLastNameEmail
1002JaneSmithjane.smith@isp.com
1003MikeJohnsonmike.johnson@hosting.com
1005TomAndersontom.anderson@isp.com

Answer:


This SQL query uses the LIKE keyword to filter the Customers table based on the Email field. The '%' character in the LIKE patterns is a wildcard that matches any sequence of characters. Therefore, '%@isp.com' matches any email ending with "@isp.com" and '%@hosting.com' matches any email ending with "@hosting.com". The query returns all columns for the matching customer records.

SQL Question 9: Analyzing customer behavior based on game purchase and usage

Nexon is a global video game company that specializes in building online communities. The company would like to understand the behavior of their customer base by analyzing game purchases and usage. The team is specifically interested in the count of unique customers who have bought any game and logged into the game within the last 30 days.

Two tables are available for this analysis: and .

Example Input

purchase_idcustomer_idgame_idpurchase_date
112300108/10/2022
226500208/12/2022
336200308/20/2022
419200209/10/2022
598100309/18/2022

Example Input

login_idcustomer_idgame_idlogin_date
112300109/10/2022
226500209/12/2022
336200309/20/2022
419200210/10/2022
598100110/18/2022

The columns of the tables are:

  • : The ID of the game purchase
  • : The ID of the customer who bought the game
  • : The ID of the game bought
  • : The date the game was bought
  • : The login ID
  • : The date customer logged in to the game

Write a SQL Query to find out the count of unique customers who have purchased any game and logged into that game in the last 30 days.

Answer:


This query performs an inner join on the and tables with the condition that both the and match across the tables. This ensures we're looking at logins for games that were actually purchased by the customer. It also uses a WHERE clause to filter down to purchases and logins that are in the past 30 days. Finally, it uses to find the count of unique customers who have both purchased a game and logged into it within the last 30 days.

Because joins come up so often during SQL interviews, try an interactive Spotify JOIN SQL question: Spotify JOIN SQL question

SQL Question 10: How do the SQL commands and differ?

No, in 99% of normal cases a and do NOT produce the same result.

You can think of more as set addition when it combines the results of two tables.

You can think of a more as set multiplication, producing all combos of table 1 with combos of table 2.

SQL Question 11: Calculate player stats

Nexon wants to evaluate player behavior in one of their games to develop new features and tweaks. Specifically, they need to understand the average, minimum, and maximum time spent by users playing the game each day, and the total time spent across all days. They also want to know the total number of users who logged into the game each day, and the square root of total time spent by the users on any day. For simplicity, assume there is no data error and daily time spent by users is logged properly.

Input:
activity_iduser_idgame_datetime_spent
11002021-07-01120
21012021-07-01130
31002021-07-02140
41022021-07-02150
51032021-07-03160
61042021-07-03110
Example Output:
game_datenum_playersmin_time_spentavg_time_spentmax_time_spenttotal_time_spentsqrt_total_time
2021-07-01212012513025015.81
2021-07-02214014515029017.03
2021-07-03211013516027016.43

Answer:


The provided PostgreSQL query first groups the data by . It then calculates the number of distinct players (), minimum time spent (), average (), maximum (), and total time () that the players spent in the game. It also computes the square root of the total time spent (), which is rounded to two decimal places for better readability. The resulting data is an overview of player activity for each game date.

To practice a very similar question try this interactive Snapchat Sending vs. Opening Snaps Question which is similar for calculating and analyzing time spent users or this Amazon Server Utilization Time Question which is similar for calculating total time around a specific action.

Nexon SQL Interview Tips

Assuming that you've already got basic SQL skills, the next best tip we have to prepare for the Nexon SQL interview is to solve as many practice SQL interview questions as you can! In addition to solving the earlier Nexon SQL interview questions, you should also solve the 200+ SQL coding questions which come from companies like Microsoft, Google, Amazon, and tech startups. DataLemur Questions

Each exercise has hints to guide you, fully explained answers along with a discussion board to see how others solved it and crucially, there is an online SQL code editor so you can right online code up your SQL query and have it executed.

To prep for the Nexon SQL interview it is also a great idea to solve SQL problems from other tech companies like:

But if your SQL coding skills are weak, forget about going right into solving questions – go learn SQL with this SQL tutorial for Data Scientists & Analysts.

DataLemur SQL Course

This tutorial covers SQL concepts such as CASE/WHEN/ELSE statements and joins – both of which pop up frequently in SQL job interviews at Nexon.

Nexon Data Science Interview Tips

What Do Nexon Data Science Interviews Cover?

In addition to SQL interview questions, the other question categories to practice for the Nexon Data Science Interview are:

Nexon Data Scientist

How To Prepare for Nexon Data Science Interviews?

To prepare for Nexon Data Science interviews read the book Ace the Data Science Interview because it's got:

  • 201 interview questions taken from Facebook, Google & startups
  • a refresher on Python, SQL & ML
  • over 900+ reviews on Amazon & 4.5-star rating

Ace the Data Science Interview Book on Amazon