开发者

Order by is not working

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开发者_StackOverflow社区 End DESC
)
Select * from Results
Where RowNumber BETWEEN @FirstRow AND @LastRow
 END

Whatever is passed in @sortDir and @sortCol it does not work.What am I doing wrong?


Moving the order by clause to the Row_Number argument list could solve your problem.

Order by in with clause is not permitted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜