Postgresql 通过唯一的一组列值分配组号
Postgresql assign group number by unique set of column values
在我看来,我想为行分配组号。组被描述为来自某些 table 列的一组值。
Fiddle: https://dbfiddle.uk/?rdbms=postgres_12&fiddle=8ea36c234ba378f08d2a870b5f695bba
你似乎想要row_number()
:
select column1, row_number() over (partition by column1 order by column1) as group_nr
from t;
Here 是一个 db<>fiddle.
在我看来,我想为行分配组号。组被描述为来自某些 table 列的一组值。
Fiddle: https://dbfiddle.uk/?rdbms=postgres_12&fiddle=8ea36c234ba378f08d2a870b5f695bba
你似乎想要row_number()
:
select column1, row_number() over (partition by column1 order by column1) as group_nr
from t;
Here 是一个 db<>fiddle.