回答編集履歴
1
追記
answer
CHANGED
@@ -5,4 +5,32 @@
|
|
5
5
|
```
|
6
6
|
play_task.plan_id = 1 or play_task.plan_id is null
|
7
7
|
```
|
8
|
-
ということですか?
|
8
|
+
ということですか?
|
9
|
+
# 追記
|
10
|
+
```SQL
|
11
|
+
insert into amount_day( amount_day,
|
12
|
+
APLAN,
|
13
|
+
APLANcount,
|
14
|
+
BPLAN,
|
15
|
+
BPLANcount,
|
16
|
+
CPLAN,
|
17
|
+
CPLANcount )
|
18
|
+
select
|
19
|
+
play_task.play_day,
|
20
|
+
sum((play_task.plan_id = 1)*plan.main_time) as s1,
|
21
|
+
sum(play_task.plan_id = 1) as c1,
|
22
|
+
sum((play_task.plan_id = 2)*plan.main_time) as s2,
|
23
|
+
sum(play_task.plan_id = 2) as c2,
|
24
|
+
sum((play_task.plan_id = 3)*plan.main_time) as s3,
|
25
|
+
sum(play_task.plan_id = 3) as c3
|
26
|
+
from play_task left join plan on
|
27
|
+
play_task.plan_id = plan.id
|
28
|
+
group by play_day
|
29
|
+
on duplicate key update
|
30
|
+
APLAN=values(APLAN),
|
31
|
+
APLANcount=values(APLANcount),
|
32
|
+
BPLAN=values(BPLAN),
|
33
|
+
BPLANcount=values(BPLANcount),
|
34
|
+
CPLAN=values(CPLAN),
|
35
|
+
CPLANcount=values(CPLANcount)
|
36
|
+
```
|