Reputation: 9
I have a table products
with prices
and colours
columns. I need a view to get the top five most expensive products for each colour.
How would I do that?
Upvotes: 0
Views: 223
Reputation: 3950
this will do :
select * from (select a.*,rank() over (partition by colour order by price desc) rk from
tableaname a) where rk<6;
rather this:
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;
Upvotes: 1