私はproduct_id列、store_id、x列を持つtable_aを持っています。Postgresシーケンシング複合キー
私は
create table_b as
select store_id, product_id, sequence_number
from table_a
SEQUENCE_NUMBERは次のように見えるようになっている、自動生成された番号であるにしたい:
store_id | product_id | sequence_number
1 | 1 | 1
1 | 1 | 2
1 | 1 | 3
1 | 2 | 1
1 | 2 | 2
2 | 1 | 1
2 | 1 | 2
は、SQLクエリでこれを行うには、それは可能ですか?
あなたは 'ROW_NUMBER()'を探しています:http://www.postgresql.org/docs/current/static/tutorial-window.html –