回答編集履歴
2
追記
test
CHANGED
@@ -9,3 +9,15 @@
|
|
9
9
|
where TGT.ID=SRC.ID
|
10
10
|
|
11
11
|
```
|
12
|
+
|
13
|
+
単に順序を付けて並び替えたいだけなら、
|
14
|
+
|
15
|
+
```SQL
|
16
|
+
|
17
|
+
select *, rank() over(order by time, id) as rank
|
18
|
+
|
19
|
+
from テーブル名
|
20
|
+
|
21
|
+
order by time, id
|
22
|
+
|
23
|
+
```
|
1
修正
test
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
```SQL
|
4
4
|
|
5
|
-
update テーブル名 set id=src.NewID
|
5
|
+
update テーブル名 TGT set id=src.NewID
|
6
6
|
|
7
|
-
from (select rank() over(order by time, id) as NewID from テーブル名) as src
|
7
|
+
from (select ID, rank() over(order by time, id) as NewID from テーブル名) as src
|
8
|
+
|
9
|
+
where TGT.ID=SRC.ID
|
8
10
|
|
9
11
|
```
|