Your question is Write SQL for Top Five Investments. 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.
Write a SQL query to find the top five performing investments based on historical data at eVestment.
Use the investment and historical performance records. Calculate each investment's average non-null historical return, including only investments with at least two recorded returns.
investment_id, investment_name, average_return, and return_observations.investment_id ascending.| Column | Type | Description |
|---|---|---|
| investment_idPK | INT | Unique investment identifier |
| investment_name | VARCHAR(150) | Investment name |
| strategy | VARCHAR(80) | Investment strategy classification |
| Column | Type | Description |
|---|---|---|
| performance_idPK | INT | Unique performance record identifier |
| investment_id | INT | Referenced investment |
| performance_date | DATE | Date of the historical observation |
| return_pct | DECIMAL(8,4) | Historical percentage return |