I have got Table:
id name amount
--------------------------
1 abc 1
2 abc 2
3 abc -3
4 def 4
I want to get sum of every amounts of name==abc, i mean 1+2+(-3) = 0;
How to do this in MySql?
SELECT SUM(amount) FROM table WHERE name = 'abc';
不确定mySQL,但是“标准” SQL将是:
select sum(amount) from yourTableName where name='abc'
SELECT SUM(amount) AS total FROM table WHERE name = 'abc'
SELECT name, SUM(amount) from Table GROUP BY name;
SELECT SUM(amount)
FROM tableName
WHERE name='abc'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.