Is it possible to sort the results of a PagedTable by one of the columns aliases?
Here is my working query:
SELECT * FROM
(
SELECT
DI.P_ID as IDEA_ID,
DI.P_IDEA_NUMBER as IDEA_NUMBER,
CASE WHEN len(DI.P_TITLE) < 1 then 'None recorded' else DI.P_TITLE END as IDEA_TITLE,
CASE WHEN len(DI.P_IDEA_MANAGER) < 1 then 'None' ELSE isnull((Select top 1 FName+' 'LName from OTHERSERVER.OTHERDB.dbo.Usernames as UN1 where (XID=DI.P_IDEA_MANAGER) order by endDate desc),'No longer on record') end as IDEA_MANAGER,
CASE WHEN len(DI.P_RELEASE_MONTH) < 1 or len(DI.P_RELEASE_YEAR) < 1 then 'None recorded' else DI.P_RELEASE_MONTH+'/'+DI.P_RELEASE_YEAR END as IDEA_REQUESTED_RELEASE,
SIS.LABEL as IDEA_STATUS,
ROW_NUMBER() OVER(Order by DI.P_IDEA_NUMBER ASC) as RowNum
FROM
DATA_IDEA as DI
LEFT OUTER JOIN
SEL_IDEA_STATUS as SIS on SIS.ID=(SELECT TOP 1 S_ID from DATA_IDEA_STATUS as DIS where (DIS.P_ID=DI.P_ID) order by created desc)
WHERE
(SIS.IS_DRAFT='True')
)
as PagedTable where (RowNum between 1 and 10)
With this I am sorting the results by the "Idea Number", which is 1,2,3, etc. Instead of sorting by "DI.P_IDEA_NUMBER", is it possible to sort instead by "IDEA_NUMBER"?
You're probably thinking this isn't that big of a deal, sorting by the idea number. Well, I'm also going to have to have the results sortable by the "IDEA_MANAGER". IDEA_MANAGER will be one of three things, based on the case statemnt. 1) John Smith, 2) None Recorded, 3)No longer on record