select product_id,product_name,total_sales_amount,total_sales_quantity from( select product_id, product_name, total_sales_amount, total_sales_quantity, rank() over(order by total_sales_quantity desc) as rk from (select t1.product_id product_id,t2.product_name product_name, sum(sales_amount) total_sales_amount, sum(sales_quantity) total_sales_quantity from sales_records t1 join products t2 on t1.product_id = t2.product_id where sales_date between '2024-01-01' and '2024-12-31' group by t1.product_id ) t3 ) t4 where rk = 1 order by product_id