Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Top Models Per Asset Class

MediumSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Top Models Per Asset Class. Start with the requirements and the two tables on the right.

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.

Problem

Balyasny Asset Management wants to compare research models within each asset class using their evaluation returns. Write a PostgreSQL query that identifies the three highest performance ranks for each asset class.

Requirements

  1. Calculate each model's average return_pct during the first quarter of 2025.
  2. Rank models within their asset class using DENSE_RANK, with the highest average return ranked first.
  3. Return every model whose dense rank is 3 or lower, including ties at the third rank.
  4. Exclude models with no non-null evaluation returns, and order the results by asset class, rank, and average return descending.

Schema

research_models
ColumnTypeDescription
model_idPKINTUnique research model identifier
model_nameVARCHAR(100)Name of the research model
asset_classVARCHAR(50)Asset class assigned to the model
launched_onDATEDate the model was launched
model_performance
ColumnTypeDescription
performance_idPKINTUnique performance evaluation identifier
model_idINTReferenced research model
evaluation_dateDATEDate of the performance evaluation
return_pctDECIMAL(8,4)Model return percentage for the evaluation period
Tablesresearch_modelsmodel_performance
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results