回答編集履歴
2
リンク修正
test
CHANGED
@@ -66,4 +66,4 @@
|
|
66
66
|
|
67
67
|
[https://docs.aws.amazon.com/ja_jp/athena/latest/ug/presto-functions.html](https://docs.aws.amazon.com/ja_jp/athena/latest/ug/presto-functions.html)
|
68
68
|
|
69
|
-
[https://masahikosawada.github.io/2018/07/07/Window-Frame/](https://masahikosawada.github.io/2018/07/07/Window-Frame/)
|
69
|
+
[https://masahikosawada.github.io/2018/07/07/Window-Frame/#rangeモード](https://masahikosawada.github.io/2018/07/07/Window-Frame/#rangeモード)
|
1
追記
test
CHANGED
@@ -21,3 +21,49 @@
|
|
21
21
|
FROM TBL AS Z
|
22
22
|
|
23
23
|
```
|
24
|
+
|
25
|
+
---
|
26
|
+
|
27
|
+
追記 2021/11/27
|
28
|
+
|
29
|
+
当方Amazon Athenaを使用出来る環境にないのですが
|
30
|
+
|
31
|
+
マニュアルを見るところwindow関数が使えるようなので
|
32
|
+
|
33
|
+
window関数を使ったSQLは以下のようになると思われます。
|
34
|
+
|
35
|
+
ただし、RANGEフレームは使用出来ない可能性が高いと思います。
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
```sql
|
40
|
+
|
41
|
+
SELECT
|
42
|
+
|
43
|
+
UID
|
44
|
+
|
45
|
+
, DAY
|
46
|
+
|
47
|
+
, 購入金額
|
48
|
+
|
49
|
+
, SUM(購入金額) OVER (
|
50
|
+
|
51
|
+
PARTITION BY UID
|
52
|
+
|
53
|
+
ORDER BY DAY
|
54
|
+
|
55
|
+
RANGE BETWEEN '1 month' PRECEDING AND CURRENT ROW
|
56
|
+
|
57
|
+
) AS 過去1か月の購入金額
|
58
|
+
|
59
|
+
FROM TBL
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
参考
|
66
|
+
|
67
|
+
[https://docs.aws.amazon.com/ja_jp/athena/latest/ug/presto-functions.html](https://docs.aws.amazon.com/ja_jp/athena/latest/ug/presto-functions.html)
|
68
|
+
|
69
|
+
[https://masahikosawada.github.io/2018/07/07/Window-Frame/](https://masahikosawada.github.io/2018/07/07/Window-Frame/)
|