Hi @mehmood tekfirst
Try this:
;WITH CTE AS
(
Select cn.Id,cn.CustomerName, cn.AgrNumber, cn.ResNumber, c.Id CarId, c.Make, c.Model, c.Group, c.Tariff, cn.StartDate, cn.EndDate
,ROW_NUMBER() OVER(ORDER BY CAST(cn .AgrNumber as int) DESC , CAST(cn .ResNumber as int) DESC) AS PageIndex
From Contract cn Left Join Cars c on cn.CarId = c.Id
)
SELECT *
FROM CTE
WHERE PageIndex > @fromRow AND PageIndex <= @toRow
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.