select a.product_id, product_name,
amt as total_sales_amount, 
qty as total_sales_quantity
from (
    select product_id, amt, qty
    from (
        select product_id, sum(sales_amount) as amt, sum(sales_quantity) as qty,
        dense_rank() over (order by sum(sales_quantity) desc) as rn
        from sales_records
        group by product_id
    ) temp
    where rn=1
) a join products b on a.product_id=b.product_id