您尝试执行查询而不是聚合函数的一部分 [英] You tried to execute query not part of aggregate function

查看:63
本文介绍了您尝试执行查询而不是聚合函数的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT  a.staff,a.logiodate,a.LogInTime,a.LogOutTime,a.nodeid
 FROM (SELECT   NGAC_USERINFO.username AS Staff, Int([Logtime]) AS LogIODate, Format(Min(NGAC_LOG.logtime),"h:m:s") AS LogInTime, Format(Max(NGAC_LOG.logtime),"h:m:s") AS LogOutTime,nodeid 
FROM NGAC_LOG INNER JOIN NGAC_USERINFO ON NGAC_LOG.userid = NGAC_USERINFO.userid WHERE ( NGAC_LOG.nodeid=1 AND ((Int([logtime])) Between  #21/09/2016# And #21/09/2016 23:59:59#)) 
GROUP BY  NGAC_USERINFO.username, NGAC_LOG.Userid, Int([Logtime]), Int([Logtime]), nodeid ) AS A
 INNER JOIN NGAC_TERMINAL ON A.nodeid=NGAC_TERMINAL.nodeid 
group by staff,logiodate,LogInTime,LogOutTime,a.nodeid
having LogInTime>'9:45:00'





我的尝试:



亲切帮助

提前感谢



What I have tried:

kindly help
thanks in advance

推荐答案

您的查询结合了两个选择查询。只有内部查询使用聚合函数(即Min,Max,Sum,Avg,Count),因此只有内部查询必须具有 GROUP BY 子句。

外部查询本身不使用任何聚合函数,它只显示内部查询计算的聚合值。因此,它必须没有 GROUP BY 子句。您可以省略它或用 ORDER BY 子句替换它。
Your query combines two select queries. Only the inner query uses "aggregate" functions (i.e. Min, Max, Sum, Avg, Count), so only the inner query must have a GROUP BY clause.
The outer query itself does not use any aggregate functions, it only displays the aggregate values calculated by the inner query. Hence it must not have a GROUP BY clause. You can omit it or replace it by an ORDER BY clause.


这篇关于您尝试执行查询而不是聚合函数的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆