我正在尝试对在 VOIP 平台上运行的 PHP 应用程序生成的特定“报告”进行故障排除(与计费相关)。要求我这样做的人说“它以前有效”;)
抛出 MySQL 错误:
1111: Invalid use of group function
疯狂的是,它“之前工作过”,但过了一会儿就停止了,他们无法确定发生了什么事件可能导致了这个错误。一种想法可能是 MYSQL 升级了?我用谷歌搜索了这个错误,似乎找不到明确的答案。
乍一看,你们看到 SQL 有什么问题吗?
SELECT C.ResourceGroupID AS CustomerID, CS.CustomerName, SUM(C.IN_RndDuration/60) AS Minutes, SUM(CASE WHEN (C.OUT_Duration>0 AND C.IN_RndDuration>0) THEN 1 ELSE 0 END) AS Successfull, count(0) AS Attempts
FROM ws_call_current AS C
LEFT JOIN customer_rg AS V_RG ON
V_RG.RGId=C.OtherResourceGroupID AND V_RG.RateTableId IS NOT NULL AND V_RG.Direction='O'
LEFT JOIN customer AS V ON V.CustomerId=V_RG.CustomerId
LEFT JOIN customer_rg AS CS_RG ON CS_RG.RGId=C.ResourceGroupID AND CS_RG.RateTableId IS NOT NULL AND CS_RG.Direction='I'
LEFT JOIN customer AS CS ON CS.CustomerId=CS_RG.CustomerId
WHERE DATE_FORMAT(DATE_ADD(C.SeizeDate, INTERVAL TIME_TO_SEC(C.SeizeTime) SECOND), '%Y-%m-%d %H:%i:00') BETWEEN '2010-10-19 00:00:00' AND '2010-10-19 23:59:59'
AND C.SeizeDate BETWEEN '2010-10-19' AND '2010-10-19'
GROUP BY CS.CustomerName
ORDER BY SUM(C.IN_RndDuration/60) DESC
我相信这是为 MYSQL 3/4 编写的,但还不确定。只是想得到一些反馈。从谷歌搜索结果中,我发现有些人通过将查询修改为 aHaving
而不是 a 来成功解决了这个问题where
。
没有把握。下面有什么奇怪的吗?