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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

top Rows

Status
Not open for further replies.

ratzp

Programmer
Dec 30, 2005
49
IN
How to get from the Third Row to Second Last Row from a Table in one RecordSet
 
You could...

1. Insert the data in to a temp table or table variable with an identity column.

2. Find the max value of the identity column

3. Then select the data from the temp table where the identity column is between 3 and (max - 1).

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
If you have an identity field you could try something like this:

Code:
create table #TEST (ID int)

insert into #test
select 1
union select 2
union select 3
union select 4 
union select 5 
union select 6
union select 7
union select 8
union select 9
union select 10

select * from #TEST
where ID > ((select min(ID) from #TEST) + 1) and ID < (select max(ID) from #TEST)



A wise man once said
"The only thing normal about database guys is their tables".
 
Good morning George :)

A wise man once said
"The only thing normal about database guys is their tables".
 
How to get from the Third Row to Second Last Row from a Table in one RecordSet

return the entire table

then, when processing it, skip the first two rows, and also skip the last two

;-) ;-)

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top