如何通过分组对列lname中的值求和

时间:2017-02-17 10:07:17

标签: php mysql

在lname下有3个名字,每次添加产品时这些名称和值都插入到其他表中,从那里我想通过分组名称来总结,还有如何通过限制日期和人名来安排它

riyas 1/1/2016 - car = 1
sara 2/1/2016 - bike = 2
riyas 3/1/2016 - car = 1
riyas 4/1/2016 - cycle = 10
sara 5/1/2016 - bike = 2

例如:car = 2,bike = 4,cycle = 10

<?php <$query_check_credentials = "SELECT lname SUM(af) AS total_amount FROM customer GROUP BY lname";$result = mysql_query($query_check_credentials); while($row = mysql_fetch_array( $result )){echo $row['total_amount'];}?>

0 个答案:

没有答案