If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Other > Selecting a particular record

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-18-02, 10:06
glenstobbs glenstobbs is offline
Registered User
 
Join Date: Mar 2002
Location: Somerset, UK
Posts: 1
Question 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
glen@glenstobbs.com
http://www.glenstobbs.com
Reply With Quote
  #2 (permalink)  
Old 03-19-02, 20:03
BrendtHess BrendtHess is offline
Registered User
 
Join Date: Jan 2002
Posts: 10
Try something like this:

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

We are the music makers, and We are the dreamers of dreams...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On