Click here to Skip to main content
15,909,193 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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
Posted
Updated 28-Sep-16 20:59pm

1 solution

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.
 
Share this answer
 
Comments
neeraj_ 29-Sep-16 3:08am    
thanks sir its done
Maciej Los 29-Sep-16 7:18am    
5ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900