如图的一个报表:
PHP从mssql读取数据,合计行用什么方式求出。
这是部份代码,比如要求金额一列的合计,在表的最后一行显示合计以什么方式显示出并计算,谢谢各位老手指教!!
$query = "Select top 35 A.Branchdesc,sum(B.Amount)totalFrom BaseBranch A Inner Join Retail B On A.BranchID=B.BranchIDWhere B.DoneFlag=1 and B.DelFlag=0 and RetailType<>1 and Convert(varchar(12),B.WorkDate,112)='$searchdata'Group by A.Branchdesc order by total desc";$result = mssql_query($query); echo "$searchdata 的销售为:";echo "
门店 | 金额 |
$row[0] | $row[1] |
回复讨论(解决方案)
$total = array('合计', 0);while($row = mssql_fetch_array($result)) { echo ""; $total[1] += $row[1];}echo " $row[0] $row[1] ";echo ""; $total[0] $rotal[1]
$total = array('合计', 0);while($row = mssql_fetch_array($result)) { echo ""; $total[1] += $row[1];}echo " $row[0] $row[1] ";echo ""; $total[0] $rotal[1]
谢谢,正确了。新手还有好多函数需要学习!以后还有许多问题需要请教,再次感谢!