By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
with ct
as
(
select 20 as id, 'G' as name
union all
select 20,'T'
union all
select 40,'I'
union all
select 90,'A'
union all
select 90,'B'
union all
select 90,'C'
)
select dense_rank() over(order by id) newid,id,name from ct
newid | id | name |
---|---|---|
1 | 20 | G |
1 | 20 | T |
2 | 40 | I |
3 | 90 | A |
3 | 90 | B |
3 | 90 | C |
SELECT 6