回答編集履歴
1
追記
test
CHANGED
@@ -11,3 +11,23 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
```
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
# 追記
|
18
|
+
|
19
|
+
```SQL
|
20
|
+
|
21
|
+
set @today:='任意の日付';
|
22
|
+
|
23
|
+
select t1.id,t1.item_id,t1.date,t1.value,t2.shokei,t3.gokei
|
24
|
+
|
25
|
+
from sales t1
|
26
|
+
|
27
|
+
inner join (select item_id,sum(value) as shokei from sales where date<@today group by item_id) as t2 on t1.item_id=t2.item_id
|
28
|
+
|
29
|
+
inner join (select sum(value) as gokei from sales where date<@today) as t3 on 1
|
30
|
+
|
31
|
+
where date=@today
|
32
|
+
|
33
|
+
```
|