SQL Query for last rows
-
Hello, I can't find an elegant solution for the following using ASP2.0 with MS SQL 7.0 SP2: I would like to select the last 10 rows of a query without using RecordSet.MovePrevious nor using FETCH anyone has an idea ? Thanks, Steven:confused:
if you have a key that can be used for a sort order (ORDER BY) then you can say something like: SELECT TOP 10 whatever FROM whatever ORDER BY key DESC it will give the first 10 items entered into the table, ie, the bottom 10 of the recordset :) --- "every year we invent better idiot proof systems and every year they invent better idiots"
-
if you have a key that can be used for a sort order (ORDER BY) then you can say something like: SELECT TOP 10 whatever FROM whatever ORDER BY key DESC it will give the first 10 items entered into the table, ie, the bottom 10 of the recordset :) --- "every year we invent better idiot proof systems and every year they invent better idiots"
Thanks Lauren, I figured that out myself too :) The problem is that I want the last ten rows displayed in ascending order without having to use RecordSet.Previous. The recordset should contain the last ten rows (I know the value of last item in the table regarding to the query) in ascending order so I can display them using while vRS.EOF = False Then vRs.MoveNext ...and I don't want to swim through a big recordset using FETCH... any ideas ? Thanks, Steven
-
Thanks Lauren, I figured that out myself too :) The problem is that I want the last ten rows displayed in ascending order without having to use RecordSet.Previous. The recordset should contain the last ten rows (I know the value of last item in the table regarding to the query) in ascending order so I can display them using while vRS.EOF = False Then vRs.MoveNext ...and I don't want to swim through a big recordset using FETCH... any ideas ? Thanks, Steven
are you processing the results on the server before display? if so you could do the previous suggestion and simply run a flip algorithm on the results set in memory reasons like this stop me using recordset objects :) --- "every year we invent better idiot proof systems and every year they invent better idiots"
-
Hello, I can't find an elegant solution for the following using ASP2.0 with MS SQL 7.0 SP2: I would like to select the last 10 rows of a query without using RecordSet.MovePrevious nor using FETCH anyone has an idea ? Thanks, Steven:confused: