Thursday, August 26, 2010

Get Nth record from Table

Hello Friends Here is a simple query to get nth Record from Table
SELECT @NewPriority=Priority 
FROM (    SELECT 
                 Id
                , Priority
                , ROW_NUMBER() OVER (ORDER BY priority) as row 
         FROM Job 
         where IsDeleted=0     
               and Id not in ( select jobId from Job_Cylinder where IsDeleted=0)
       ) a
WHERE row=@cnt-(@NewPriority)+1
There are many ways to get this.. All the Best

No comments: