select
product_id,
product_name,
type,
price
from
(
select
product_id,
price,
type,
product_name,
rank() over (
partition by
type
order by
price desc
) as ranking
from
product_info
) ss
where
ranking < 3
order by
price desc,
product_id asc
limit
3

京公网安备 11010502036488号