Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcdinh/173823 to your computer and use it in GitHub Desktop.
Save pcdinh/173823 to your computer and use it in GitHub Desktop.
WITH PostList AS (
SELECT row_number() OVER (ORDER BY p.PostID DESC) Row,
p.PostID, p.ThreadID, p.ParentID, p.SortOrder,
p.PostDate, p.Subject, p.SectionID ForumID, p.PostAuthor UserName,
p.UserID UserID, p.IPAddress, t.ThreadDate, cast(p.[Body] as text) Body
FROM cs_Posts p
INNER JOIN cs_Threads t ON t.ThreadID = p.ThreadID
INNER JOIN cs_Sections s ON s.SectionID = p.SectionID
WHERE s.ApplicationType = 0
)
SELECT *
FROM PostList
WHERE Row BETWEEN 0 AND 300
ORDER BY PostID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment