cancel
Showing results for 
Search instead for 
Did you mean: 

paging in sql server

Former Member
0 Kudos
1,917

I am new to sql and I am in trouble of fetching data from sql server using paging method.

I have one table having Primary column,DateModified and other fields. table having 4lac records.

I want to implement paging using sql server.

Conditions: 1] First column must be row number. 2] Latest modified records must be come first using DateModified columns 3] Perfomance must be high.

I have problem in query.

Suppose, I use

select * from (Select row_number() over(order by SoldProductId) as rowNum,SoldProductId, OtherId,DateModified From table1 order by DateModified desc ) as TempTable where rowNum between 1 and 10

query. Then due to order by clause this query doest work.

Suppose, I use

select * from (Select row_number() over(order by SoldProductId) as rowNum,SoldProductId, OtherId,DateModified From table1 ) as TempTable where rowNum between 1 and 10

query.It doesnt returns latest records first.

How Can I solve this problem.

Please Help!!!

Accepted Solutions (0)

Answers (0)