任何人都可以建议我查询错误。
SELECT SUM(cCallDuration), COUNT(*), AVG(cCallduration),
cBeginTime, cEndTime, cAnswerTime, cCallDuration, cDispatcherName, cConsoleName,
cEndpointName, cProfileName, cCallDirection, cCallType,
cCallNature, cCallData, cDirectedCall
FROM CALLINFO
WHERE cBeginTime >='7/11/2011 12:00:00 AM'
AND cEndTime <='7/11/2011 12:00:00 AM'
AND cCallType='InBound'
GROUP BY cConsoleName
我收到了这个错误:
在聚合和分组表达式中,SELECT子句可以 仅包含聚合和分组 表达式。 [选择条款= ,cBeginTime]
答案 0 :(得分:2)
您必须在GROUP BY子句中有更多内容
查看此示例。每个非聚合列都包含在GROUP BY中。你也必须这样做
SELECT Customer,OrderDate,SUM(OrderPrice) FROM Orders
GROUP BY Customer,OrderDate
试试这个:
SELECT SUM(cCallDuration), COUNT(*), AVG(cCallduration),
cDispatcherName, cConsoleName,
FROM CALLINFO
WHERE cBeginTime >='7/11/2011 12:00:00 AM'
AND cEndTime <='7/11/2011 12:00:00 AM'
AND cCallType='InBound' GROUP BY cConsoleName,cDispatcherName
所以要完成你的完整sql语法,你必须在GROUP BY子句中包含不是聚合的每一列,这意味着除SUM,AVG和COUNT之外的每一列
答案 1 :(得分:1)
GROUP BY子句: SELECT 列表中任何nonaggregate表达式中的列必须包含在GROUP BY列表中。
SELECT SUM(cCallDuration), COUNT(*), AVG(cCallduration),
cBeginTime, cEndTime, cAnswerTime, cCallDuration, cDispatcherName, cConsoleName,
cEndpointName, cProfileName, cCallDirection, cCallType,
cCallNature, cCallData, cDirectedCall
FROM CALLINFO
WHERE cBeginTime >='7/11/2011 12:00:00 AM'
AND cEndTime <='7/11/2011 12:00:00 AM'
AND cCallType='InBound' GROUP BY
cBeginTime, cEndTime, cAnswerTime, cCallDuration, cDispatcherName, cConsoleName,
cEndpointName, cProfileName, cCallDirection, cCallType,
cCallNature, cCallData, cDirectedCall