题解 | 哪些产品在特定时间段内表现最为出色
哪些产品在特定时间段内表现最为出色
https://www.nowcoder.com/practice/866a4614615b43a29750537ede4bf0c8
with temp as
(
select
product_id,
product_name,
sum(sales_amount) as total_sales_amount,
sum(sales_quantity) as total_sales_quantity
from
sales_records
join products using (product_id)
where
year(sales_date) = 2024
group by
product_id
order by total_sales_amount desc ,product_id asc
)
select
product_id,
product_name,
total_sales_amount,
total_sales_quantity
from temp
where total_sales_quantity=(select max(total_sales_quantity) from temp)


