Given the following code, from the answer to this question, how can I adapt it for paging? I've read that Common Table Expression is a good way to do paging, but since I implemented CTE to solve a problem that was already over my head, I really have no idea where to start in merging the two solutions.
;with cte as
(
SELECT DISTINCT d.AppId,
d.AppName,
d.AppType,
Tags = STUFF((SELECT ', ' + t.TagName
FROM AppTags t
where d.AppID = t.AppID
FOR XML PATH (''))
, 1, 1, '')
FROM AppDetails d
WHERE d.AppID = '1'
)
select *
from cte
where tags like '%test1%'