Order by Id differs order by CreationDate

1

Please login or register to vote for this query.

(click on this box to dismiss)

Moderators

Q&A for community managers, administrators, and moderators

WITH Raw AS (
  SELECT Id, RANK() OVER (ORDER BY Id) AS NId, CreationDate
  FROM PostsWithDeleted
)
SELECT
  Prev.Id AS PrevId,
  Prev.NId AS PrevNid,
  Prev.CreationDate AS PrevCreationDate,
  'site://posts/' + CAST(Prev.Id AS VARCHAR(MAX)) + '/timeline|timeline'
    AS PrevTimeline,
  Next.Id AS NextId,
  Next.NId AS NextNid,
  Next.CreationDate AS NextCreationDate,
  'site://posts/' + CAST(Next.Id AS VARCHAR(MAX)) + '/timeline|timeline'
    AS NextTimeline
FROM Raw AS Prev, Raw AS Next
WHERE
  Next.Id = Prev.Id + 1
  AND
  Prev.CreationDate > Next.CreationDate

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results