-
Hey guy's
I need to get the three most recently entered items from SQL table .. I have a Index field in the table that increments by 1 everytime a new value is entered.
I tried this
*******
Set rsResults = conn.Execute("SELECT TOP 3 Head_Index, Head_Headline, Head_Time FROM Headlines")
********
but all this gives me is the top three values in the table. How can I get the 3 bigest Index values out of the table?
Thanks in advance!
-
If you have an index field that's incremented by 1 for each new record then what you could do is put an ORDER BY clause on your SQL statement to sort descending by your increment field. That way you'd be grabbing the 'top 3' from a reverse sorted list - and in effect be grabbing the 'bottom 3'. Something like:
Code:
Set rsResults = conn.Execute("SELECT TOP 3 Head_Index, Head_Headline, Head_Time FROM Headlines ORDER BY YourIncrementedIndexFieldName DESC")
Paul
-
add 'order by index' to your statement, that should do the job
good luck
-
Schweat!
Thanks guy's it worked!!!!
-
:-(
-
Oops! Sorry
Ok then
Thanks ALL it worked and for the Female programmers out there Have a Good One!!!! :-)
Cheers