修改某一字段数据的问题如下,我有一个表ANO1 NO2 month
1 4 1
2 6 1
3 8 1
4 5 1
5 8 1
6 8 1
1 3 2
2 4 2
3 5 2 我想得到如下表NO1 NO2 month
1 100 1
2 101 1
3 102 1
4 103 1
5 104 1
6 105 1
1 106 2
2 107 2
3 108 2 我根据NO1字段和MONTH字段为条件,修改NO2字段,请指教,谢谢
1 4 1
2 6 1
3 8 1
4 5 1
5 8 1
6 8 1
1 3 2
2 4 2
3 5 2 我想得到如下表NO1 NO2 month
1 100 1
2 101 1
3 102 1
4 103 1
5 104 1
6 105 1
1 106 2
2 107 2
3 108 2 我根据NO1字段和MONTH字段为条件,修改NO2字段,请指教,谢谢
''内填值
UPDATE A SET NO2=ROWNUM+99
set no2=(select rn+100-1 from (select no1,month,
row_number()over(order by month,no1)rn from a)
where no1=t.no1 and month=t.month)
或
update a t
set no2=(select count(1)+100-1 from a where month<t.month or (month=t.month and no1<t.no1))