题解 | 哪些产品在特定时间段内表现最为出色
哪些产品在特定时间段内表现最为出色
https://www.nowcoder.com/practice/866a4614615b43a29750537ede4bf0c8
select
product_id,
product_name,
sum(sales_amount) total_sales_amount,
sum(sales_quantity) total_sales_quantity
from products
join sales_records using(product_id)
where year(sales_date) = "2024"
group by 1,2
having sum(sales_quantity) >= all (
select
sum(sales_quantity)
from sales_records
where year(sales_date) = "2024"
group by product_id
)
order by 1
三种解法,窗口函数筛选,子查询,all函数,暂时只想到了这么多
查看16道真题和解析