回答編集履歴

1

追記

2016/12/26 03:54

投稿

yambejp
yambejp

スコア114839

test CHANGED
@@ -13,3 +13,27 @@
13
13
  なんらかの連番処理が必要であればSQL側でランキングを計算する手法が
14
14
 
15
15
  幾つか用意されています。(ただし効率は悪いです)
16
+
17
+
18
+
19
+ # sample
20
+
21
+ ```SQL
22
+
23
+ create table tbl (id int not null unique key,val varchar(20));
24
+
25
+ insert into tbl values(1,'aaa'),(2,'bbb'),(4,'ccc'),(50,'ddd'),(999,'eee');
26
+
27
+ create view vw as select id,(select count(*)+1 from tbl as t2 where t1.id>t2.id) as renban,val from tbl as t1;
28
+
29
+ ```
30
+
31
+
32
+
33
+ 表示
34
+
35
+ ```SQL
36
+
37
+ select * from vw;
38
+
39
+ ```