-
Help CR and SQL Server
i'm trying to create a simple report to show daily log on.
Query on my SQL Server is : Select distinct ( fullname ) , eventdatetime from log where eventdatetime > '02-18-2004'.
based upon my user is logging many times a day , i would like to know how can i only show the first or the last time he logged.
Thanks in advance.
-
I can't try it right not because I'm not at the office but here's a quick idea that would probably work. Sort it ASC or DESC based on the date and query using
SELECT TOP 1 DISTINCT.....
-
OK this should work:
SELECT MAX(eventdatetime) FROM log WHERE EXISTS
(SELECT DISTINCT fullname, eventdatetime FROM log WHERE eventdatetime > '02/18/2004')
AND fullname = 'fullname'
You can use MAX or MIN to get the Hi and Low values of the date.
-