您如何计算mysql表的特定列中的整数?
+------------+--------+
| product_id | stores |
+------------+--------+
| 371374 | 1 |
| 283994 | 1 |
| 232191 | 2 |
| 131127 | 1 |
| 284000 | 1 |
| 371383 | 1 |
| 83 | 3 |
| 131156 | 1 |
| 371385 | 1 |
| 284004 | 1 |
+------------+--------+
我想计算所有商店,如1 + 1 + 2 + 1 + ......
答案 0 :(得分:2)
SELECT SUM(stores) FROM tablename
答案 1 :(得分:1)
尝试:
SELECT SUM(stores)
FROM mytable
答案 2 :(得分:0)
尝试此查询
select sum(stores) from <tablename>;
答案 3 :(得分:0)
SELECT SUM( stores ) AS sum
FROM `table_name`