Table: Prices
Column Name | Type |
---|---|
product_id | int |
start_date | date |
end_date | date |
price | int |
(product_id,start_date,end_date) 是 Prices 表的主键。
Prices 表的每一行表示的是某个产品在一段时期内的价格。
每个产品的对应时间段是不会重叠的,这也意味着同一个产品的价格时段不会出现交叉。
Table: UnitsSold
Column Name | Type |
---|---|
product_id | int |
purchase_date | date |
units | int |
UnitsSold 表没有主键,它可能包含重复项。
UnitsSold 表的每一行表示的是每种产品的出售日期,单位和产品 id。
问题
编写SQL查询以查找每种产品的平均售价。
average_price 应该四舍五入到小数点后两位。