With Results as
(
SELECT Top(100) percent ROW_NUMBER() over (Order by (select 1)) as RowNumber,
Ad.Date, Title
FROM Ad inner join Job on Ad.Id = Job.AdId
Order by
case When @sortCol='Date' and @sortDir='ASC' Then Date End ASC,
case When @sortCol='Date' and @sortDir='DESC' Then Date End DESC
)
Select * from Results
Where RowNumber BETWEEN @FirstRow AND @LastRow
END
无论在@sortDir和@sortCol中传递什么,它都不起作用。我做错了什么?
答案 0 :(得分:3)
将order by
子句移动到Row_Number
参数列表可以解决您的问题。
Order by
是不允许的。