select a.product_id,a.product_name,a.type,a.price from (select dense_rank() over(PARTITION BY type ORDER BY price DESC ) as rank_id, product_id,product_name,type,price from product_info ) as a where rank_id<=2 order by a.price desc ,a.product_name limit 3