Database integration test: list of votes created before their post

1

Please login or register to vote for this query.

(click on this box to dismiss)

Looks this inconsistency is the result of question merges

Stack Overflow

Q&A for professional and enthusiast programmers

WITH Raw AS (
  SELECT
    Votes.Id AS VoteId,
    PostsWithDeleted.Id AS PostId,
    PostsWithDeleted.Id AS [Post Link],
    DATEFROMPARTS(
      DATEPART(yyyy, PostsWithDeleted.CreationDate),
      DATEPART(mm, PostsWithDeleted.CreationDate),
      DATEPART(day, PostsWithDeleted.CreationDate)
    ) AS PostDay,
    Votes.CreationDate AS VoteDay
  FROM PostsWithDeleted, Votes
  WHERE
    PostsWithDeleted.Id = Votes.PostId
)
SELECT *, DATEDIFF(day, VoteDay, PostDay) AS DaysBefore
FROM Raw
WHERE VoteDay < PostDay
ORDER BY DaysBefore DESC, PostId;

Enter Parameters

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