回答編集履歴
4
訂正
test
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
集計の単位が違うものは別々に集計するしかありません。
|
2
2
|
|
3
3
|
```SQL
|
4
|
-
|
5
|
-
with session_Max as (
|
6
4
|
|
7
5
|
select date, url, avg(scroll_depth) as scroll_depth
|
8
6
|
|
3
訂正
test
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
集計の単位が違うものは別々に集計するしかありません。
|
2
|
-
|
3
|
-
これらを一度に取得する場合は、「小計」のような行が必要で、unionでこれを追加します。
|
4
2
|
|
5
3
|
```SQL
|
6
4
|
|
7
5
|
with session_Max as (
|
8
6
|
|
7
|
+
select date, url, avg(scroll_depth) as scroll_depth
|
8
|
+
|
9
|
+
from (
|
10
|
+
|
9
11
|
select FORMAT_TIMESTAMP("%Y-%m-%d", timestamp, "Asia/Tokyo") AS date
|
10
12
|
|
11
|
-
, url
|
13
|
+
, url
|
12
14
|
|
13
15
|
, session_id
|
14
16
|
|
@@ -18,22 +20,8 @@
|
|
18
20
|
|
19
21
|
group by date, url, session_id
|
20
22
|
|
21
|
-
)
|
23
|
+
) session_Max
|
22
24
|
|
23
|
-
select * from session_unit
|
24
|
-
|
25
|
-
union all
|
26
|
-
|
27
|
-
select date
|
28
|
-
|
29
|
-
, url, 'url_Avg'
|
30
|
-
|
31
|
-
, Null
|
32
|
-
|
33
|
-
, avg(scroll_depth) as scroll_depth
|
34
|
-
|
35
|
-
FROM session_Max
|
36
|
-
|
37
|
-
|
25
|
+
group by date, url
|
38
26
|
|
39
27
|
```
|
2
推敲
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
```SQL
|
6
6
|
|
7
|
-
with session_
|
7
|
+
with session_Max as (
|
8
8
|
|
9
9
|
select FORMAT_TIMESTAMP("%Y-%m-%d", timestamp, "Asia/Tokyo") AS date
|
10
10
|
|
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
, avg(scroll_depth) as scroll_depth
|
34
34
|
|
35
|
-
FROM session_
|
35
|
+
FROM session_Max
|
36
36
|
|
37
37
|
group by date, url
|
38
38
|
|
1
推敲
test
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
これらを一度に取得する場合は、「小計」のような行が必要で、unionでこれを追加します。
|
4
4
|
|
5
5
|
```SQL
|
6
|
+
|
7
|
+
with session_unit as (
|
6
8
|
|
7
9
|
select FORMAT_TIMESTAMP("%Y-%m-%d", timestamp, "Asia/Tokyo") AS date
|
8
10
|
|
@@ -16,17 +18,21 @@
|
|
16
18
|
|
17
19
|
group by date, url, session_id
|
18
20
|
|
21
|
+
)
|
22
|
+
|
23
|
+
select * from session_unit
|
24
|
+
|
19
25
|
union all
|
20
26
|
|
21
|
-
select
|
27
|
+
select date
|
22
28
|
|
23
|
-
, url, 'url_
|
29
|
+
, url, 'url_Avg'
|
24
30
|
|
25
31
|
, Null
|
26
32
|
|
27
33
|
, avg(scroll_depth) as scroll_depth
|
28
34
|
|
29
|
-
FROM
|
35
|
+
FROM session_unit
|
30
36
|
|
31
37
|
group by date, url
|
32
38
|
|