Skip to main content

Total Transaction Volume

Hard

Given the e-commerce database schema below, write a SQL query to fetch the total transaction value in dollars (USD) for the product line "Telephones" and return it as total_amount_in_dollars.

You will need to use the exchange_rate table

Keep in mind that the amount field represents hundredths of the base currency.

Round up the result to two decimal points.

users products +---------------+---------+ +-----------------+---------+ +--| id | int | +-----| id | int | | | first_name | varchar | | | name | varchar | | | last_name | varchar | | +->| product_line_id | date | | | user_city | int | | | | stock | int | | | email | int | | | +-----------------+---------+ | +---------------+---------+ | | | | | | transactions | | product_lines | +---------------+---------+ | | +--------+--------+ +---->| id | int |<----+ +--| id | int | | customer_id | int | | name | varchar| | product_id | int | +--------+--------+ | amount | int | | currency_code | varchar | | date | date | +---------------+---------+ exchange_rate +----------------------+---------+ | id | int | | source_currency_code | varchar | | target_currency_code | varchar | | rate | numeric | +----------------------+---------+

Your answer should return a result with the following format:

total_amount_in_dollars ------------------------- float