Results 1 to 4 of 4

Thread: Help CR and SQL Server

  1. #1

    Thread Starter
    Registered User
    Join Date
    Nov 2002
    Posts
    12

    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.

  2. #2
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    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.....

  3. #3
    Hyperactive Member ARPRINCE's Avatar
    Join Date
    Mar 2003
    Location
    Pinoy in NJ
    Posts
    381
    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.

  4. #4

    Thread Starter
    Registered User
    Join Date
    Nov 2002
    Posts
    12
    Thank you very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width