Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2012
    Posts
    7

    Unanswered: high low card time

    I was hoping someone could help with the following issue. I am trying to sort out the first time someone swipes their door access card and the last time they swipe their door access card each day. I have the below query:

    SELECT Sheet1.[emp_id], Sheet1.[card_date], Sheet1.[card_time]
    FROM Sheet1;

    However, this gives me a list of each time a person cards in/cards out for each day. I would like to just have the name listed once for each date and the first time swiped and last time swiped for each date.

    Any help is greatly appreciated! Thanks!!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT emp_id
         , card_date
         , MIN(card_time) AS earliest
         , MAX(card_time) AS latest
      FROM Sheet1
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    SELECT emp_id
         , card_date
         , Min(card_time) As earliest_card_time
         , Max(card_time) As latest_card_time
    FROM   sheet1
    GROUP
        BY emp_id
         , card_date
    George
    Home | Blog

  4. #4
    Join Date
    Apr 2012
    Posts
    7
    Simply amazing. Thank you!

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    aaaaaaargh, george, can you believe what i did

    started writing the sql and got distrac....
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    We all make mistrakes
    George
    Home | Blog

Posting Permissions

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