我有一个products
表,其中包含prices
和colours
列。 我需要一种视图才能获得每种颜色的前五种最昂贵的产品。 我该怎么做?
这将
可以:
select * from (select a.*,rank() over (partition by colour order by price desc) rk from
tableaname a) where rk<6;
而是这个:
CREATE VIEW view_name AS select * from (select a.*,rank() over (partition
by colour order by price desc) rk from
tableaname a) where rk<6;