Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
Window Functions for Time Ranking
00:00
5 left

Window Functions for Time Ranking

HardSQL · PostgreSQL

Problem

How would you use window functions to rank players by performance over time on PrizePicks?

Use the provided PrizePicks player, game, and performance data. Return rankings only after a player has three valid completed-game performances.

Output

  1. One row per eligible player and completed game, with player_id, player_name, sport, game_date, performance_score, rolling_3_game_avg, prior_performance, performance_change, and performance_rank.
  2. Rank players within the same sport and game date by rolling average, with ties sharing a rank.
  3. Order by sport, game_date, performance_rank, and player_id.

Schema

players
ColumnTypeDescription
player_idPKINTUnique player identifier
player_nameVARCHAR(100)Player display name
sportVARCHAR(20)Player sport
games
ColumnTypeDescription
game_idPKINTUnique game identifier
sportVARCHAR(20)Sport associated with the game
game_dateDATEScheduled game date
statusVARCHAR(20)Game status, such as final or scheduled
player_game_stats
ColumnTypeDescription
stat_idPKINTUnique performance record identifier
player_idINTReferenced player
game_idINTReferenced game
performance_scoreDECIMAL(10,2)PrizePicks performance score
Tablesplayersgamesplayer_game_stats
Interviewer

Your question is Window Functions for Time Ranking. Start with the requirements and the three tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.