2011-08-01 58 views
-2

嗨我怎樣才能計算mysql表的特定列中的整數?在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 + ...

回答

2

SELECT SUM(stores) FROM tablename

1

嘗試:

SELECT SUM(stores) 
    FROM mytable 
0

嘗試此查詢

select sum(stores) from <tablename>; 
0
SELECT SUM(stores) AS sum 
FROM `table_name`