select
class,
price
from (
select
class,
price,
row_number() over (partition by class order by price) rn
from complex
) prices
where
(class=1 and rn < 3) -- 2 econom
or (class=2 and rn < 4) -- 3 comfort
or (class=3 and rn < 2) -- 1 premium
;