SashaSQL
SashaSQL

Reputation: 33

How to add column with a certain type of number sequence of

There are lots of answers for adding a column to a table with some increment; e.g. start at 1 and increment by 1; e.g. 1, 2, 3 etc.

I need to add a column to tables that starts at 1, and increments by 1, but each number is repeated some number of times before the next number in the sequence.

For example: 100 rows of 1, then 100 rows of 2, etc. until the end of the table.

Upvotes: 0

Views: 1198

Answers (1)

Dale K
Dale K

Reputation: 27224

Options based on what you have said:

  1. Create a view and generate the sequence number using row_number() over ()/100
  2. Create a regular identity column and then create a computed column which is your identity column divided by 100 using integer division.
  3. Create a regular int column and run a manual update on it using row_number() over ()/100.

Upvotes: 3

Related Questions