这是我的mysql查询
SELECT IntervalStartTime,IFNULL(SUM(AbandonedCalls),0) AS AbandonedCallSum,SUM(QueueTime) AS QTS,SUM(RingTime) AS RTS,
IFNULL(SUM(AnsweredCalls),0) AS AnsweredCallSum
FROM intervalqueuestatistics
WHERE CallCenterId=17 AND DATE_FORMAT(IntervalStartTime,'%m')=10 AND DATE_FORMAT(IntervalStartTime,'%Y')=2012
GROUP BY DATE_FORMAT(IntervalStartTime,'%d');
现在我想计算一个值(SUM(QueueTime)+SUM(RingTime))/SUM(AnsweredCalls)
所以我相应地修改了我的查询,如下所示
SELECT IntervalStartTime,IFNULL(SUM(AbandonedCalls),0) AS AbandonedCallSum,SUM(QueueTime) AS QTS,SUM(RingTime) AS RTS,
IFNULL(SUM(AnsweredCalls),0) AS AnsweredCallSum,IFNULL(SUM(QueueTime),0) + IFNULL(SUM(RingTime),0)/IFNULL(SUM(AnsweredCalls),0)
FROM intervalqueuestatistics
WHERE CallCenterId=17 AND DATE_FORMAT(IntervalStartTime,'%m')=10 AND DATE_FORMAT(IntervalStartTime,'%Y')=2012
GROUP BY DATE_FORMAT(IntervalStartTime,'%d');
但是当执行它并没有给我正确的答案。
例如此查询返回的行之一
QTS RTS AnsweredCallSum CalculatedField
188000 41645 9 192627.222
但是CalculatedField是错误的,根据上面的计算应该是25516.11