How to pick only last 5 most recent records

Results 1 to 3 of 3

Thread: How to pick only last 5 most recent records

  1. #1
    Join Date
    Dec 1969
    Posts
    78

    Default How to pick only last 5 most recent records

    Can someone show me the sql to select only the 5 most recent records from a given database? I&#039;ve got a table that&#039;s got about 50 records, but i&#039;m displaying them in a datalist and only want the user to see the last 5. thanks.<BR><BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    18,177

    Default You have to have some..

    .. indicator of WHICH are the last 5 - an incrementing ID, a create date, something.<BR><BR>Then, it&#039;s just:<BR>select top 5 field, field from table order by id desc

  3. #3
    Join Date
    Dec 1969
    Posts
    78

    Default RE: You have to have some..

    that did it...thanks!!!

Posting Permissions

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