Here is my request:
DECLARE @StartRow INT DECLARE @PageSize INT SET @StartRow = 1 SET @PageSize = 5 SELECT ContractID,Property FROM ( SELECT c.ContractID, Property = ( SELECT TOP 1 p.Name FROM Com.Property p JOIN VContract.Contract2Property c2p ON c2p.PropertyID=p.PropertyID WHERE c2p.ContractID=c.ContractID ), ROW_NUMBER() OVER (ORDER BY Property) as RowNum FROM VContract.[Contract] c ) as sub WHERE RowNum BETWEEN @StartRow AND ((@StartRow + @PageSize) - 1)
The problem is (ORDER BY Property). I can order c.ContractID, but not a property. So how can this be achieved? I need to find the name of the property, and then I want to sort by that name.
This is used to populate the website, so it is important that paging is very important to me, so I can limit how many records are returned once.
Thanks for any help.
source share