Your question is Profit Increase From FX Conversion. Start with the requirements and the three 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.
DRW's quantitative analytics team compares Company A's quarterly profitability in EUR, although source profit records are stored in USD. Exchange rates vary by date, so each profit record must be converted before aggregation.
Write a PostgreSQL query that calculates the percentage increase in Company A's EUR-denominated profit from the first to the last month of Q1 2025.
profit_usd * eur_per_usd, then aggregate by month.| Column | Type | Description |
|---|---|---|
| company_idPK | INT | Unique company identifier |
| company_name | VARCHAR(100) | Company name |
| Column | Type | Description |
|---|---|---|
| profit_idPK | INT | Unique profit record identifier |
| company_id | INT | References companies.company_id |
| profit_date | DATE | Date of the profit record |
| profit_usd | NUMERIC(18,2) | Profit amount in USD |
| Column | Type | Description |
|---|---|---|
| rate_datePK | DATE | Date for the USD to EUR rate |
| eur_per_usd | NUMERIC(10,6) | EUR value of one USD |