8 Perfect World Entertainment SQL Interview Questions (Updated 2024)

Updated on

March 3, 2024

At Perfect World Entertainment, SQL is typically used for analyzing player behavior patterns and optimizing the performance of online gaming servers. Because of this, Perfect World Entertainment almost always asks SQL query questions in interviews for Data Science, Data Engineering and Data Analytics jobs.

To help you ace the Perfect World Entertainment SQL interview, we've curated 8 Perfect World Entertainment SQL interview questions – can you answer each one?

8 Perfect World Entertainment SQL Interview Questions

SQL Question 1: Identify Power Users in Perfect World Entertainment

Perfect World Entertainment is primarily recognized for its strong portfolio of online games. To keep a track of user activity and identify VIP users, we want to analyze the user_gameplay table. A VIP user is defined as a user who played any of their games for more than 1000 hours in the past month. Write a SQL query to find out the user_id and the total gameplay hours of these power users.

Example Input:


Here's a SQL block that could answer the problem:

This SQL query first filters out all the play records in the current month using the WHERE clause. After that, it groups the records by user_id and calculates the total play time for each user in the past month by the sum function in the SELECT statement. Finally, it filters out users with total play times more than 1000 hours by the HAVING clause. So the result of this SQL query is the user_id and total play time of VIP users.

To solve a similar VIP customer analysis question on DataLemur's free interactive SQL code editor, try this Microsoft Azure Cloud SQL Interview Question: Microsoft SQL Interview Question: Super Cloud Customer

SQL Question 2: Calculate the Monthly Sum of In-Game Purchase

As a data analyst for Perfect World Entertainment, a popular gaming company, you are asked to analyze and provide insights about in-game purchases for their popular game "Heaven of Swords". The company wants to understand about monthly trends in in-game purchases, for that you need to write a SQL query to calculate the sum of in-game purchase for each month, for each user.

Example Input:
873112306/05/2022 00:00:0074200330
895226506/12/2022 00:00:0074200370
952936206/15/2022 00:00:0074200350
1083519207/20/2022 00:00:0074200390
1013098107/13/2022 00:00:0074200360
Example Output:


The query above employs the PostgreSQL window function . What it does is it groups the data by user_id and orders by year and month of purchase_date, then calculates the sum for each group. The statement is used to filter the data specifically for game "Heaven of Swords". The function is used to pull out only the month from the purchase_date and year respectively.

For more window function practice, solve this Uber SQL problem within DataLemur's interactive coding environment:

Uber Data Science SQL Interview Question

SQL Question 3: What is the purpose of a primary key in a database?

A primary key is a column or set of columns in a table that uniquely identifies each row in the table. The primary key is used to enforce the uniqueness and non-nullability of the rows in the table.

In a SQL database, a primary key is defined using the constraint. For example, say you had a table of :

In this example, the column is the primary key of the Perfect World Entertainment employees table. It is defined as an integer and is marked as the primary key using the constraint.

A table can have only one primary key, but the primary key can consist of multiple columns. For example, say you had a table of Perfect World Entertainment customer transactions:

In the above example, the primary key of the Orders table consists of two columns: TransactionID and ProductID. This means that the combination of OrderID and ProductID must be unique for every row in the table.

Perfect World Entertainment SQL Interview Questions

SQL Question 4: Click-Through-Rate Analysis for Perfect World Entertainment

Perfect World Entertainment is a leading online publisher of live service games in North America and Europe. They are known for creating games that foster powerful communities. They are interested in understanding the click-through rates of their demos to actual purchases for their games.

They track two main events:

  1. when a user clicks on a game demo ('demo_click')
  2. when a user makes a purchase after playing the demo ('demo_purchase')

The data is logged in two separate tables, and .

Example Input:


Example Input:


Write a SQL query to calculate the percentage of demo clicks that result in a purchase for each game. This will help Perfect World Entertainment understand which games have the highest conversion rate from demo to purchase.


This query works by joining the and tables on and . It counts the distinct number of users who made a purchase (represented by ) and divides it by the total number of users who clicked the demo (represented by ). We use to ensure that the result is a decimal number. The result is grouped by to get the click-through-to-purchase ratio for each game.

To solve a similar problem about calculating rates, try this TikTok SQL question within DataLemur's online SQL code editor: TikTok SQL question

SQL Question 5: Can you explain what SQL constraints are, and why they are useful?

In a database, constraints are rules that the DBMS (database management system) follows when performing operations such as inserting, updating, or deleting data.

For example, consider a table of employee records at Perfect World Entertainment. Some constraints that you might want to implement include:

  • NOT NULL: This constraint ensures that certain columns, such as the employee's first and last name, cannot be NULL.
  • UNIQUE: This constraint ensures that each employee has a unique employee ID.
  • PRIMARY KEY: This constraint combines the NOT NULL and UNIQUE constraints to create a primary key for the employee table. The primary key is a column or set of columns that uniquely identifies each row in the table.
  • FOREIGN KEY: This constraint establishes a relationship between the employee table and other tables in the database. For example, you could use a foreign key to link the employee ID to the department ID in a department table to track which department each employee belongs to.
  • DEFAULT: This constraint specifies a default value for a column in case no value is specified when a new row is inserted into the table.

SQL Question 6: Joining and Analyzing Customer and Game Data

Given the following two tables, and , write a SQL query to list out the average spending of customers on different games.

table contains customer information including customer id, name, and registration date. table contains transactional data such as game id, customer id, transaction date, and amount spent on the games.

For the output, provide a table listing out the customer names along with the average spending on each unique game.

Example Input:
101John Doe2020-01-10
102Jane Smith2020-02-15
103Jim Brown2020-03-20
104Janet Wilson2020-04-25
105Jennifer Lewis2020-05-30
Example Input:


This query first joins the and tables on the field. The clause is then used to group records by unique customer and game pairs (i.e. it considers each customer's spending on separate game as a unique condition). function is then used to calculate average spending of each customer on each individual game. Finally, the results are ordered by customer names.

Since joins come up so often during SQL interviews, practice an interactive Spotify JOIN SQL question: SQL join question from Spotify

SQL Question 7: What does the operator do?

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 Perfect World Entertainment 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 Perfect World Entertainment, and had access to Perfect World Entertainment'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:

SQL Question 8: Analysis of Player Login Patterns

Perfect World Entertainment wants to analyze the login habits of their players. Given the table of login timestamps, can you write a query to find out the players who have logged in daily for more than seven consecutive days? The start and end date of each players consecutive login span should also be included in your output.

Example Input:

10892022-07-08 15:09:55
10892022-07-09 17:43:25
10892022-07-10 11:34:02
10892022-07-11 07:08:14
10892022-07-12 21:15:06
10892022-07-13 19:34:11
10892022-07-14 23:23:45
10892022-07-15 08:00:55
30212022-07-12 10:08:01
30212022-07-13 12:46:25

Example Output:



In this solution, we first partition the table by and order by , and subtract a row number from the date. If the players logged in on consecutive days, then this would result in a constant value which helps to group the consecutive dates (grp). Then, in the outer query, we compute the minimum and maximum date for each group and the player_id, and only keep those groups that have more than 7 dates.

Preparing For The Perfect World Entertainment SQL Interview

The best way to prepare for a SQL interview, besides making sure you have strong SQL fundamentals, is to practice a ton of real SQL questions that were asked in recent job interviews. In addition to solving the earlier Perfect World Entertainment SQL interview questions, you should also solve the 200+ FAANG SQL Questions on DataLemur which come from companies like Google, Uber, and Microsoft. DataLemur Questions

Each interview question 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 instantly run your SQL query and have it graded.

To prep for the Perfect World Entertainment SQL interview it is also helpful to practice interview questions from other tech companies like:

But if your SQL foundations are weak, forget about going right into solving questions – improve your SQL foundations with this DataLemur SQL Tutorial.

SQL tutorial for Data Analytics

This tutorial covers things like filtering data with boolean operators and transforming strings with CONCAT()/LOWER()/TRIM() – both of which pop up often during SQL job interviews at Perfect World Entertainment.

Perfect World Entertainment Data Science Interview Tips

What Do Perfect World Entertainment Data Science Interviews Cover?

Beyond writing SQL queries, the other question categories to practice for the Perfect World Entertainment Data Science Interview are:

Perfect World Entertainment Data Scientist

How To Prepare for Perfect World Entertainment Data Science Interviews?

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

  • 201 interview questions taken from FAANG, tech startups, and Wall Street
  • a crash course covering SQL, AB Testing & ML
  • over 900+ reviews on Amazon & 4.5-star rating

Ace the Data Science Interview Book on Amazon