Display last 5 records from a table

  • Hi,

    I have one table named "tblName" it has only two fileds like "nameid" and "NameTitle". Table contains 50 records. now my problem is that I want to display last 5 records from tblName so what is required query for this, can anyone help me out

    Thanks

    Sanket

    Regards

  • select top 5 nameid, nametitle from tblName

    order by nameid desc







    **ASCII stupid question, get a stupid ANSI !!!**

  • Hi Sushila,

    You might misunderstood my query....

    I wanted last five records that means if i have 50 records then i want records like 45,46,47,48,49 and 50th.

    Can you please check it out and waiting for reply.

    Thanks

    Sanket

    Regards

  • You mean something like this...?!?!

    select a.* from

    (select top 5 nameid, nametitle from tblName

    order by nameid desc)a

    order by a.nameid







    **ASCII stupid question, get a stupid ANSI !!!**

  • Yes it worked for me....

    Thanks

    Sanket

    Regards

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply