primary key - Auto increment depending on value of column in PostgreSQL -


the question follows, can auto increment (verification_number) depending on value of specific column (here business_uuid) verification_number increments 1 (1) depending on business_uuid's own highest number of verification_number?

database looks follows: table: verification

verification_id = integer, sequence (primary key) business_uuid = text verification_number = integer 

the verification_id primary key in table , want verification_number follow it's own auto increment depending on it's highest value filtered business_uuid.

the business_uuid unique identifier each business.

is possible?

it not clear if want verification_number saved table possible create @ query time:

select verification_id, business_uuid,      row_number() over(         partition business_uuid         order verification_id     ) verification_number verification 

the problem above approach verification_number change if rows deleted

window functions


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -