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
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess 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
Build my plan
Window Functions for Asset Ranking
00:00
5 left

Window Functions for Asset Ranking

MediumSQL · PostgreSQL

Problem

Write a SQL query using window functions to find the top-performing energy assets per region over the last quarter. Use the energy_assets and asset_performance tables, and treat performance as total production_mwh during the previous calendar quarter.

Output

  1. Return one row per top-performing asset, including ties.
  2. Include region, asset_id, asset_name, total_generation_mwh, and performance_rank.
  3. Sort by region ascending, performance_rank ascending, and asset_id ascending.

Schema

energy_assets
ColumnTypeDescription
asset_idPKINTUnique energy asset identifier
asset_nameVARCHAR(100)Displayed name of the energy asset
regionVARCHAR(50)Operating region for the asset
asset_typeVARCHAR(30)Technology type of the asset
statusVARCHAR(20)Current operating status
asset_performance
ColumnTypeDescription
performance_idPKINTUnique performance reading identifier
asset_idINTReferenced energy asset
reading_dateDATEDate of the production reading
production_mwhDECIMAL(12,2)Energy production in megawatt-hours
Tablesenergy_assetsasset_performance
Interviewer

Your question is Window Functions for Asset Ranking. Start with the requirements and the two 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.