回答編集履歴
1
参考
answer
CHANGED
@@ -1,2 +1,15 @@
|
|
1
1
|
見た感じ、なにかのランク付けじゃないですか?
|
2
|
-
id順に連番をつけているとか?
|
2
|
+
id順に連番をつけているとか?
|
3
|
+
|
4
|
+
# sample
|
5
|
+
```SQL
|
6
|
+
create table tbl(id int not null unique,val int);
|
7
|
+
insert into tbl values(5,1),(7,2),(3,3),(1,4),(8,5);
|
8
|
+
```
|
9
|
+
|
10
|
+
```SQL
|
11
|
+
select (select count(*)+1 from tbl as t2 where t2.id<t1.id) as rank,id,val
|
12
|
+
from tbl as t1 order by rank;
|
13
|
+
|
14
|
+
```
|
15
|
+
|