Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2002
    Somerset, UK

    Question Unanswered: Selecting a particular record

    Using ASP I am calling records from a table where a username = cookie username. That's the easy part, and it works fine. Even sorting by date works fine. BUT, I want to select the second last record (by date) - I tried a SELECT TOP ...... but it still gives me the data from the latest record.

    What I am trying to achieve is a lookup to see when last somone visited a webpage. The page they open writes to the stats table on entry, so the data showing their last visit is ... well, Today (cos it just called the record it wrote a millisecond ago!

    Any help would be greatly appreciated. I am now almost bald thanks to my dabbling in ASP etc!

    Glen R Stobbs

  2. #2
    Join Date
    Jan 2002
    Try something like this:

    SELECT TOP 1 * FROM MyTable WHERE MyDate < (Select Top 1 MyDate FROM MyTable WHERE UserID = 'whatever') AND UserID = 'Whatever'

    We are the music makers, and We are the dreamers of dreams...

Posting Permissions

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