简体   繁体   English

我有select返回的表,如何计算field2的总和,其中f1相似?

[英]I have table returned by select, how to calculate sum of field2, where f1 is similar?

f1              f2
guest           100
tester          0
user            200
user            200

desired result:想要的结果:

f1              f2
guest           100
user            400
tester          0
SELECT f1, SUM(f2)
FROM your_table
GROUP BY f1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python3 + DB:“从`table`中选择*,其中`field` IN(...)和`field2` =&#39;…&#39;” - Python3 + DB: “Select * from `table` where `field` IN (…) AND `field2` = '…'” 如何选择field2永远不是x的所有非唯一field1? - How can I select all non-unique field1s where field2 is never x? 如何插入到TABLE1(field1,field2&#39;value&#39;,&#39;myval&#39;,&#39;currentdate&#39;)从TABLE2选择(field1,field2) - How to insert into TABLE1 (field1,field2 'value','myval','currentdate') select(field1,field2) from TABLE2 SELECT * FROM表WHERE字段IN(SELECT id FROM table ORDER BY field2) - SELECT * FROM table WHERE field IN (SELECT id FROM table ORDER BY field2) MYSQL仅在field1或field2不等于文本的情况下选择field1,field2 - MYSQL select field1, field2 only where field1 or field2 does not equal text mysql相关子查询:选择field1,其中max(field2) - mysql correlated subquery : select field1 where max(field2) MySQL-选择field1和field2都大于0的地方 - MySQL - Select where both field1 and field2 are greater than 0 Mysql在哪里查询…选择* where field1 + field2 + field3 &lt;=字段4 - Mysql where query… select * where field1 +field2 + field3 <= field 4 如何在条件中找到Sum(字段),即“select * from sum of sum(field)&lt;150” - how to find Sum(field) in condition ie “select * from table where sum(field) < 150” MySQL:如何从一个表中选择和显示所有行,并计算另一个表中where子句的总和? - MySQL: How to select and display ALL rows from one table, and calculate the sum of a where clause on another table?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM