Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help get the nth record from sql table? or the the last nth record? 1

Status
Not open for further replies.

grungekid

Programmer
Jan 22, 2004
6
NL
hi all,

I have read somewhere that sql server 2000 does not store the row numbers so you cant pick a set list of rows, i.e row 1500 to 1800.

if this is true how can i write an sql query to get the last 15000 records of my table, if at all possible

The way ive been doing it, is to order by timesstamp desc but this puts the recordset in reverse and my asp.net graph is plotted from right to left!

eg.

SELECT TOP 15000 timestamp, UV_CELL_HIGH_LIMIT_VAL0, UV_CELL_LOW_LIMIT_VAL0, UV_CELL_INNER_VAL0,UV_CELL_OUTER_VAL0,STD_CELL_B_INNER_VAL0,STD_CELL_A_OUTER_VAL0, STD_CELL_LOW_LIMIT_VAL0, STD_CELL_HIGH_LIMIT_VAL0
FROM dbo.T5_AGER_LIGHTUP
ORDER BY timestamp

maybe there a way in asp, im using VB.Net in codebehind, to reverse the data in the datareader!

i have googled all morning and cant find a thing to help me?

thanks
 

try
Code:
SELECT * FROM 
(SELECT TOP 15000 timestamp, UV_CELL_HIGH_LIMIT_VAL0, UV_CELL_LOW_LIMIT_VAL0, UV_CELL_INNER_VAL0,UV_CELL_OUTER_VAL0,STD_CELL_B_INNER_VAL0,STD_CELL_A_OUTER_VAL0, STD_CELL_LOW_LIMIT_VAL0, STD_CELL_HIGH_LIMIT_VAL0
FROM dbo.T5_AGER_LIGHTUP
ORDER BY timestamp) tmp
order by Timestamp desc


"I'm living so far beyond my income that we may almost be said to be living apart
 
i just changed it to this:-

SELECT * FROM (SELECT TOP 15000 timestamp, UV_CELL_HIGH_LIMIT_VAL0, UV_CELL_LOW_LIMIT_VAL0, UV_CELL_INNER_VAL0, UV_CELL_OUTER_VAL0,STD_CELL_B_INNER_VAL0, STD_CELL_A_OUTER_VAL0, STD_CELL_LOW_LIMIT_VAL0, STD_CELL_HIGH_LIMIT_VAL0 FROM dbo.T5_AGER_LIGHTUP ORDER BY timestamp DESC) tmp
ORDER BY timestamp

it works excellent thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top