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!!! asked 05 Apr '12, 00:33 Kaushik Halv... |
This is a forum on Sybase SQL Anywhere (formerly named Sybase Adaptive Server Anywhere). If you're asking for Microsoft SQL Server, I would recommend a different forum/newsgroup.
Confine the FAQ.
Assuming that you really are using SQL Anywhere, it might help if you provided an example of what you would like to see as the result set. For example, based on your description of the table, I picture data like this:
So how you want this sorted (i.e., what does your result set look like)?
Your first query produces this result which I understand is not what you want.