我有一张具有此格式的表格
id value1 value2 value3 value3/value2
1 16.1 97.2 39 0.401
2 150 89 26 0.29
3 145 14 70 5
df 62 44 93 2.11
我想计算每个值的每个唯一ID的总和,以及value3 / value2。
以下是我最后采取的一个例子。
{{1}}
我如何使用MySQL并将它们保存到新表中?
答案 0 :(得分:0)
select id,
sum(value1) as value1,
sum(value2) as value2,
sum(value3) as value3,
sum(value3) / sum(value2) as value2_3
from your_table
group by id
你可以把它放在另一个像这样的表中
insert into new_table (col1, col2, col3, col4, col5)
select id,
sum(value1) as value1,
sum(value2) as value2,
sum(value3) as value3,
sum(value3) / sum(value2) as value2_3
from your_table
group by id