chinnybloke
04-12-2006, 06:45 AM
Hello,
I have a table of user logon/logoff times. It only contains:
User ID
When they logged on
When they logged off
(logon/logoff times are DateTime in SQL Server 2005).
A user can logon and off several times during the day but I am trying to make a query that returns all first logons by each user for each day.
My query is basically:
SELECT WHO_SIGNED_ON, MIN(WHEN_SIGNED_ON) As Expr1
FROM LOGON_TABLE
GROUP BY WHO_SIGNED_ON
This returning the earliest logon by user, not the earliest for each day. How do I make it also group by just the date part of the DateTime column WHEN_SIGNED_ON?
I know this is bound to be relatively simple but I cannot see the wood for the trees!
Thanks in advance for any tips,
CB
I have a table of user logon/logoff times. It only contains:
User ID
When they logged on
When they logged off
(logon/logoff times are DateTime in SQL Server 2005).
A user can logon and off several times during the day but I am trying to make a query that returns all first logons by each user for each day.
My query is basically:
SELECT WHO_SIGNED_ON, MIN(WHEN_SIGNED_ON) As Expr1
FROM LOGON_TABLE
GROUP BY WHO_SIGNED_ON
This returning the earliest logon by user, not the earliest for each day. How do I make it also group by just the date part of the DateTime column WHEN_SIGNED_ON?
I know this is bound to be relatively simple but I cannot see the wood for the trees!
Thanks in advance for any tips,
CB