Order by is not working
Posted
by
coure06
on Stack Overflow
See other posts from Stack Overflow
or by coure06
Published on 2010-12-31T08:26:09Z
Indexed on
2010/12/31
8:54 UTC
Read the original article
Hit count: 256
sql-server
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
Whatever is passed in @sortDir and @sortCol it does not work.What am I doing wrong?
© Stack Overflow or respective owner