on 2012 Apr 05 1:33 AM
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!!!
Request clarification before answering.
User | Count |
---|---|
76 | |
30 | |
8 | |
8 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.