February 7, 2018 at 4:56 am
sasil - Monday, March 15, 2010 5:36 AMHi Friends,I have a table of 1000 records of data. If i want to get data of rows from 501 to 700 from the table without using any condition what I have to do.Please suggest a solution.
select * from tablename where rownum<=700
minus
elect * from tablename where rownum<500
February 7, 2018 at 7:04 am
psmahesh115 - Wednesday, February 7, 2018 4:56 AMsasil - Monday, March 15, 2010 5:36 AMHi Friends,I have a table of 1000 records of data. If i want to get data of rows from 501 to 700 from the table without using any condition what I have to do.Please suggest a solution.select * from tablename where rownum<=700
minus
elect * from tablename where rownum<500
I always appreciate it when someone tries to improve an answer for an 8 year old post but your code won't help unless there's a fresh copy of a column called RowNum on the table. Also, "MINUS" doesn't work in SQL Server.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 7, 2018 at 7:34 am
Jeff Moden - Wednesday, February 7, 2018 7:04 AMpsmahesh115 - Wednesday, February 7, 2018 4:56 AMsasil - Monday, March 15, 2010 5:36 AMHi Friends,I have a table of 1000 records of data. If i want to get data of rows from 501 to 700 from the table without using any condition what I have to do.Please suggest a solution.select * from tablename where rownum<=700
minus
elect * from tablename where rownum<500I always appreciate it when someone tries to improve an answer for an 8 year old post but your code won't help unless there's a fresh copy of a column called RowNum on the table. Also, "MINUS" doesn't work in SQL Server.
and what if the second dataset were elected with a hanging chad? (since we're already going back in time)
-------------------------------------------------------------------------------------------------------------------------------------
Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses
February 7, 2018 at 8:03 am
Jeff Moden - Wednesday, February 7, 2018 7:04 AMpsmahesh115 - Wednesday, February 7, 2018 4:56 AMsasil - Monday, March 15, 2010 5:36 AMHi Friends,I have a table of 1000 records of data. If i want to get data of rows from 501 to 700 from the table without using any condition what I have to do.Please suggest a solution.select * from tablename where rownum<=700
minus
elect * from tablename where rownum<500I always appreciate it when someone tries to improve an answer for an 8 year old post but your code won't help unless there's a fresh copy of a column called RowNum on the table. Also, "MINUS" doesn't work in SQL Server.
You could use EXCEPT instead of MINUS, but it would still include an extra row as written.
In SQL 2012, they introduced OFFSET/FETCH specifically to handle paging.SELECT *
FROM tablename
ORDER BY somefield
OFFSET 500 ROWS
FETCH NEXT 200 ROWS ONLY
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
Viewing 4 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply