1BY LOVE SINGH,
2Here, name and id is the column name of the table tbltest.
3
4SELECT
5 name,
6 RANK () OVER (
7 ORDER BY id DESC
8 ) price_rank
9FROM
10 tbltest;
1
2
3
4
5 SELECT * FROM (
6 SELECT
7 product_id,
8 product_name,
9 brand_id,
10 list_price,
11 RANK () OVER (
12 PARTITION BY brand_id
13 ORDER BY list_price DESC
14 ) price_rank
15 FROM
16 production.products
17) t
18WHERE price_rank <= 3;