sql - Insert values into a new table with "position in group" column? -


i have table:

c1     c2   c3 ---------- 100    200 100    201 100    203 200    405 200    408 

...and table created 3 columns.

i need add values above table new table including new column like,

c1     c2   c3 -------------- 100    200   1 100    201   2 100    203   3 200    405   1 200    408   2 

...and on. c3 dependent on c1 , when c1 changed, set 1 , continue increment.

the second table created , empty.
need copy values of columns c1 , c2 of old table new table , @ same time, insert new values c3 of second table.

insert my_table2   select c1, c2         ,row_number() on (partition c1 order c1, c2)     my_table 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -