回答編集履歴
3
訂正
test
CHANGED
@@ -33,3 +33,5 @@
|
|
33
33
|
group by business_id, user_id
|
34
34
|
|
35
35
|
```
|
36
|
+
|
37
|
+
※文法エラーになっていたので修正。
|
2
訂正
test
CHANGED
@@ -8,15 +8,17 @@
|
|
8
8
|
|
9
9
|
select business_id, user_id from (
|
10
10
|
|
11
|
+
select *
|
12
|
+
|
11
|
-
|
13
|
+
, rank() over(partition by business_id, user_id order by tip_count desc) tip_rank
|
12
14
|
|
13
15
|
from (
|
14
16
|
|
15
|
-
select *, count(*) over(partion by business_id, user_id) tip_count
|
17
|
+
select *, count(*) over(partition by business_id, user_id) tip_count
|
16
18
|
|
17
|
-
, count(*) over(partion by business_id) user_count
|
19
|
+
, count(*) over(partition by business_id) user_count
|
18
20
|
|
19
|
-
, count(*) over(partion by user_id) review_count
|
21
|
+
, count(*) over(partition by user_id) review_count
|
20
22
|
|
21
23
|
from tip
|
22
24
|
|
1
推敲
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
```SQL
|
8
8
|
|
9
|
-
select
|
9
|
+
select business_id, user_id from (
|
10
10
|
|
11
11
|
select *, rank(partion by business_id, user_id ordr by tip_count desc) tip_rank
|
12
12
|
|
@@ -28,4 +28,6 @@
|
|
28
28
|
|
29
29
|
where tip_rank <= 2
|
30
30
|
|
31
|
+
group by business_id, user_id
|
32
|
+
|
31
33
|
```
|