Php MySQL-基于同一表上的同一个字段获取列值之和
我有一个名为tbl_collection的mysql表和另一个包含客户名称的表。我做了一个内部连接。Join很有效 这是我的tbl_收集表 我想得到的是每个月每个客户的金额 例如,2012-02年每个客户的每项价值总和 (每个值)30002=200+250+122=572 (每小时)30003=500=500 (每个值)30004=425+225+300=950 这就是我想做的Php MySQL-基于同一表上的同一个字段获取列值之和,php,mysql,sum,Php,Mysql,Sum,我有一个名为tbl_collection的mysql表和另一个包含客户名称的表。我做了一个内部连接。Join很有效 这是我的tbl_收集表 我想得到的是每个月每个客户的金额 例如,2012-02年每个客户的每项价值总和 (每个值)30002=200+250+122=572 (每小时)30003=500=500 (每个值)30004=425+225+300=950 这就是我想做的 $r = mysql_query("select tbl_collection.customer, sum(tbl_c
$r = mysql_query("select tbl_collection.customer, sum(tbl_collection.col_ach) as coll from tbl_collection inner join tbl_mas_customer on tbl_mas_customer.customer = tbl_collection.customer where rep = '503' and DATE_FORMAT(date, '%Y-%m') = '2012-02'");
$r = mysql_query("select tbl_collection.customer, sum(tbl_collection.col_ach) as coll from tbl_collection inner join tbl_mas_customer on tbl_mas_customer.customer = tbl_collection.customer where rep = '503' and DATE_FORMAT(date, '%Y-%m') = '2012-02'");
select customer,sum(ach_val) from tbl_collection group by customer,month(date);