At Playtech, SQL is crucial for analyzing gaming data for insights. For this reason, Playtech almost always evaluates jobseekers on SQL query questions during interviews for Data Science, Analytics, and & Data Engineering jobs.
To help you practice for the Playtech SQL interview, we've curated 8 Playtech SQL interview questions – can you answer each one?
Playtech, a gaming company, offers various video games to its users and closely monitors user engagement. Each user can play multiple games, and each game has multiple play sessions. For this exercise, consider that we have a table named outlining each play session by the user.
You are tasked to calculate the average playtime (in minutes) per user for the game titled 'Warriors Guild.' Note that the 'playtime' column in the dataset provides each play session's duration in minutes.
34 | 'Warriors Guild' | 120 | 2022-08-01 |
57 | 'Space Cadets' | 45 | 2022-08-02 |
34 | 'Warriors Guild' | 90 | 2022-08-02 |
99 | 'Warriors Guild' | 60 | 2022-08-03 |
57 | 'Magic Academy' | 110 | 2022-08-05 |
99 | 'Warriors Guild' | 30 | 2022-08-06 |
34 | 'Warriors Guild' | 85 | 2022-08-07 |
The SQL query would look something like this:
With this query, you select the and columns and calculate the average playtime for each user for the specific game titled 'Warriors Guild.' The ROUND function is used to limit the result to 2 decimal places. When you run this query against the data, it will return a new table with the , , and for the game 'Warriors Guild' per user.
For more window function practice, solve this Uber SQL Interview Question within DataLemur's online SQL coding environment:
As the database administrator for Playtech, a gaming company, your task is to determine which game in the 'games' table was played the most by users in the last month. The 'game_plays' table captures every instance a game was played. Every time a user plays a game, a new row is added with the id of the game and the id of the user. Provide the name of the game with the highest count of game plays in the last month.
game_id | game_name |
---|---|
1001 | Battlefield |
1002 | CyberPunk |
1003 | FinalFable |
1004 | PlayArena |
play_id | user_id | play_date | game_id |
---|---|---|---|
9001 | 123 | 06/08/2022 00:00:00 | 1001 |
9002 | 265 | 06/10/2022 00:00:00 | 1002 |
9003 | 362 | 06/18/2022 00:00:00 | 1003 |
9004 | 192 | 07/26/2022 00:00:00 | 1001 |
9005 | 981 | 07/05/2022 00:00:00 | 1002 |
game_id | game_name | total_plays_last_month |
---|---|---|
1001 | Battlefield | 2 |
This SQL query works by joining the 'games' table and the 'game_plays' table on the 'game_id' column. The WHERE condition filters out the plays that happened in the last month. The COUNT function is then used to count the number of times each game was played. The resulting data is grouped by 'game_id' and 'game_name' and ordered in descending order by the count of game plays. The LIMIT 1 statement returns only the game with the highest count of plays.
One way to find duplicate records in a table is by using , and then seeing which groups have more than one occurence:
Another way is by using the operator:
For Playtech, a leading company in the digital gaming industry, customer engagement is paramount. Understanding what games players are playing the most and when they are playing is crucial. The company would like to filter customer gaming data based on game names.
Assume you have a table that collects customers' playing habits. This table consists of , , , and columns.
Write a SQL query using PostgreSQL syntax that can filter customer records based on a specific game name pattern. For example, filter all records where the has "poker" in it.
The table looks something like this:
customer_id | game_name | start_time | end_time |
---|---|---|---|
2431 | "Texas Holdem Poker" | 05/15/2022 13:00:00 | 05/15/2022 14:30:00 |
7825 | "Slot Machine Deluxe" | 05/20/2022 21:00:00 | 05/20/2022 23:25:00 |
3291 | "Caribbean Stud Poker" | 05/30/2022 18:00:00 | 05/30/2022 19:45:00 |
2532 | "Vegas Slot Machine" | 06/04/2022 10:00:00 | 06/04/2022 12:15:00 |
5471 | "Poker Superstars" | 06/08/2022 22:00:00 | 06/08/2022 22:35:00 |
This query uses the LIKE keyword in SQL, combined with the '%' wildcard character. This combination allows the query to search for any which contains the word anywhere within its value. This will return all records where the has "poker" in it, regardless of case or position within the string.
A correlated sub-query is one that is linked to the outer query and cannot be executed on its own. It uses the outer query to filter or transform data by referencing a column from the outer query, while the outer query uses the results of the inner query. On the other hand, a non-correlated sub-query is independent of the outer query and can be executed on its own. It does not reference any columns from the outer query and is used to retrieve additional data for the outer query.
Correlated sub-queries are slower to execute, as they have to be re-evaluated for each row of the outer query, while non-correlated sub-queries are faster, as they only have to be executed once.
At Playtech, one of the key metrics is understanding the player behavior. For this, we need to compute and understand how often and how long a player plays a game. Given the two tables and , compute the total number of unique games each player has played and their average playtime.
The table has a column representing the player's unique ID, and other details like player's and , representing the date the player joined Playtech.
The table has a column for unique game IDs, a column , a column with a timestamp when the game started, and an with a timestamp when the game ended.
player_id | name | join_date |
---|---|---|
1001 | Bob | 01/01/2022 |
1002 | Alice | 01/15/2022 |
1003 | Charlie | 02/01/2022 |
game_id | player_id | start_time | end_time |
---|---|---|---|
101 | 1001 | 02/01/2022 10:00:00 | 02/01/2022 10:30:00 |
102 | 1001 | 02/01/2022 11:00:00 | 02/01/2022 11:50:00 |
101 | 1002 | 03/01/2022 10:00:00 | 03/01/2022 10:10:00 |
102 | 1003 | 04/01/2022 15:00:00 | 04/01/2022 15:25:00 |
103 | 1003 | 04/01/2022 19:00:00 | 04/01/2022 19:20:00 |
The above query first joins the and tables using the . The key computation lies in the clause where total unique games played by each player is counted and the average playtime is calculated by subtracting the from , converting the time interval to minutes and then averaging it. The result is also rounded to 2 decimal places for convenience of viewing.
Please, note that players that have not played any game will not be included in the result. If you want to include them, consider changing to a .
To practice a very similar question try this interactive Snapchat Sending vs. Opening Snaps Question which is similar for measuring user engagement time or this Twitter Histogram of Tweets Question which is similar for analyzing user activity.
No, in almost all cases, and for all practical purposes, and do NOT produce the same result.
While both are similar, in that they combine two tables, you can think of joins as increasing the width of the resulting table (you'll have more columns in the result set for a left/inner/right join), whereas a union is used to combine rows which increases the height of the result set but keeps the column count the same.
As a Game Analytics Manager at Playtech, you're tasked with overseeing the player engagement for your online games. One crucial metric you want to track is the average length of game sessions per game each month.
Your data is currently stored in a table. A row is added to this table any time a user starts a new game session, and the times at which they start and finish are both recorded.
Use this information to determine the average game session length (in minutes) per game each month.
session_id | user_id | game_id | session_start | session_end |
---|---|---|---|---|
101 | 123 | 51 | 2022-08-01 10:00:00 | 2022-08-01 11:20:00 |
102 | 319 | 52 | 2022-08-01 11:00:00 | 2022-08-01 11:30:00 |
103 | 215 | 51 | 2022-08-01 13:00:00 | 2022-08-01 14:30:00 |
104 | 123 | 52 | 2022-08-02 09:00:00 | 2022-08-02 11:00:00 |
105 | 189 | 51 | 2022-09-01 16:00:00 | 2022-09-01 16:50:00 |
month | game_id | avg_session_length |
---|---|---|
8 | 51 | 105 |
8 | 52 | 90 |
9 | 51 | 50 |
Here's a SQL query that will solve the problem:
This query first calculates the difference in minutes between the session_end and session_start time for each row in the table. It then groups these rows by month and game_id, and finds the average session length for each group. The result is a table that shows the average session length for each game each month.
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 Playtech SQL interview questions, you should also solve the 200+ FAANG SQL Questions on DataLemur which come from companies like Netflix, Google, and Amazon.
Each interview question has multiple hints, fully explained answers along with a discussion board to see how others solved it and best of all, there is an interactive coding environment so you can easily right in the browser your SQL query answer and have it executed.
To prep for the Playtech SQL interview it is also helpful to practice SQL questions from other tech companies like:
However, if your SQL query skills are weak, don't worry about jumping right into solving questions – refresh your SQL knowledge with this SQL interview tutorial.
This tutorial covers SQL topics like creating pairs via SELF-JOINs and aggregate functions like SUM()/COUNT()/AVG() – both of which pop up frequently during Playtech SQL assessments.
Beyond writing SQL queries, the other types of problems to practice for the Playtech Data Science Interview are:
To prepare for Playtech Data Science interviews read the book Ace the Data Science Interview because it's got: