mysql总数

时间:2012-04-08 18:25:43

标签: mysql

我有一个像这样的mysql表:

general
+----+------+
| ID | hits |
+----+------+
| 1  |  10  |
+----+------+
| 2  |  6   |
+----+------+
| 3  |  31  |
+----+------+

如何获得总点击数?

2 个答案:

答案 0 :(得分:4)

使用SUM聚合函数获取列的总数:

SELECT SUM(hits) FROM general

答案 1 :(得分:1)

SELECT SUM(hits) FROM general;