0

这是我的查询...我无法使用聚合函数 - 一次计算多个表。

$qu="SELECT distinct calls.c_number, count(type) as count1,SUM(charges * duration) as total,sum(duration) as duration1,billing_details.payment as pay,packages.(count)activation as act
 FROM calls
  INNER 
    JOIN packages
    ON calls.c_number=packages.c_number 
 WHERE

 calls.date>= DATE_FORMAT( $date, '%Y/%m/01' ) AND


calls.date< DATE_FORMAT( $date + INTERVAL 1 MONTH, '%Y/%m/01') group by c_number desc having SUM(charges * duration) > 0  "; 

它给了我这个错误:

FUNCTION packages.count does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual
4

2 回答 2

1

这与PHP没有任何关系......

这与您的顶线有关-

$qu="SELECT distinct calls.c_number, count(type) as count1,SUM(charges * duration) as total,sum(duration) as duration1,billing_details.payment as pay,packages.(count)activation as act

你期望“packages.(count)activation”做什么?你的意思是count(packages.activation)

于 2013-06-16T09:48:23.293 回答
0

尝试这个

count(packages.activation)

而不是这个

 packages.(count)activation
于 2013-06-16T09:49:34.203 回答