Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这样的情况:
- name value ------------- - stuff_1 2 - stuff2 5 - stuff2 3 - stuff_1 4
我必须使用哪个 mysql 查询来对所有这些值求和并得到如下结果:
- name value ------------- - stuff_1 2+4=6 - stuff2 5+3=8
你需要这样的东西:
select name, sum(value) from table_name group by name
看看那里列出的 MySQL GROUP BY和聚合函数
干得好:
SELECT name, SUM(value) FROM your_table GROUP BY name;