Above Average Product Prices
Start Timer
0:00:00
Given a table of transactions and products, write a query to retrieve three columns product_id, product_price, and avg_transaction_total where:
avg_transaction_totalis the average of(price * quantity)over all transactions for each product.We only want products whose
product_priceis strictly greater than their ownavg_transaction_total.
Notes: - Round the values to two decimal places.
Example:
Input:
transactions table
| Column | Type |
|---|---|
id |
INTEGER |
user_id |
INTEGER |
created_at |
DATETIME |
product_id |
INTEGER |
quantity |
INTEGER |
products table
| Column | Type |
|---|---|
id |
INTEGER |
name |
VARCHAR |
price |
FLOAT |
.
.
.
.
.
.
.
.
.
Comments