Preparing for your next Quant Interview?
Practice Here!
OpenQuant
All Questions
Next Question
Closest Median Profit
00:00:00
2/10
Data Wrangling
Parts
Part 1

The performance review cycle has begun and you are responsible for evaluating the traders at your firm. Out of curiosity, you want to find the two traders that had the closest median profit per trade with one another. Write a SQL query to return the two traders with the closest median profit along with the difference in median profit between the traders. Only include traders that had at least one trade.

Here's an example of how the output should look:

trader1_nametrader2_namemedian_profit_diff
JamesKendrick17

You are given the following tables:

traders

ColumnType
idINTEGER
nameVARCHAR

trades

ColumnType
idINTEGER
trader_idINTEGER
profitFLOAT