回答編集履歴
3
推敲
test
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
)
|
32
32
|
|
33
|
-
select
|
33
|
+
select count(*)
|
34
34
|
|
35
35
|
from (values (0),(1),(2)) as rand_test(testid)
|
36
36
|
|
2
推敲
test
CHANGED
@@ -34,8 +34,8 @@
|
|
34
34
|
|
35
35
|
from (values (0),(1),(2)) as rand_test(testid)
|
36
36
|
|
37
|
-
inner join rand
|
37
|
+
inner join rand
|
38
38
|
|
39
|
-
|
39
|
+
on rand_test.testid=rand.random_value
|
40
40
|
|
41
41
|
```
|
1
追記
test
CHANGED
@@ -13,3 +13,29 @@
|
|
13
13
|
where testid =(select trunc(random() * 3))
|
14
14
|
|
15
15
|
```
|
16
|
+
|
17
|
+
追記
|
18
|
+
|
19
|
+
--
|
20
|
+
|
21
|
+
試してみたら、サブクエリーでは駄目でしたね。
|
22
|
+
|
23
|
+
With式なら大丈夫でした。
|
24
|
+
|
25
|
+
```SQL
|
26
|
+
|
27
|
+
with rand as (
|
28
|
+
|
29
|
+
select trunc(random() * 3) as random_value
|
30
|
+
|
31
|
+
)
|
32
|
+
|
33
|
+
select testid , random_value
|
34
|
+
|
35
|
+
from (values (0),(1),(2)) as rand_test(testid)
|
36
|
+
|
37
|
+
inner join rand
|
38
|
+
|
39
|
+
on rand_test.testid=rand.random_value
|
40
|
+
|
41
|
+
```
|