Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Profit Increase From FX Conversion

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

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.

You need to log in / sign up to run or submit.

Problem

Business Context

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.

Task

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.

Requirements

  1. Join companies, profit records, and daily FX rates.
  2. Convert each USD profit using profit_usd * eur_per_usd, then aggregate by month.
  3. Ignore records with missing profit or FX values and exclude dates outside Q1 2025.
  4. Return the first month, last month, EUR profit for each, and the percentage increase rounded to two decimals.

Schema

companies
ColumnTypeDescription
company_idPKINTUnique company identifier
company_nameVARCHAR(100)Company name
profit_records
ColumnTypeDescription
profit_idPKINTUnique profit record identifier
company_idINTReferences companies.company_id
profit_dateDATEDate of the profit record
profit_usdNUMERIC(18,2)Profit amount in USD
fx_rates
ColumnTypeDescription
rate_datePKDATEDate for the USD to EUR rate
eur_per_usdNUMERIC(10,6)EUR value of one USD
Tablescompaniesprofit_recordsfx_rates
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results