You are analyzing ad revenue recorded in multiple currencies and need to compute US revenue and global revenue in USD.
Assume the following schemas:
ad_revenue
event_date
DATE
country
STRING -- ISO country code (e.g.,
US
,
CA
)
currency
STRING -- ISO currency code (e.g.,
USD
,
EUR
)
revenue_amount
NUMERIC -- amount in
currency
fx_rates
rate_date
DATE
currency
STRING
usd_per_unit
NUMERIC -- 1 unit of
currency
equals this many USD
event_date
using the FX rate from the
same date
(
fx_rates.rate_date = ad_revenue.event_date
).
country = 'US'
.
Write a SQL query to output daily totals:
event_date
us_revenue_usd
global_revenue_usd