onets

0

Please login or register to vote for this query.

(click on this box to dismiss)

Music Fans Meta

Q&A about the site for music historians, critics, and fans

-- SELECT TOP 1000 *
-- FROM PostHistory
-- WHERE PostHistoryTypeId = 12

;with records
as
(
  SELECT a.PostID, 
         a.CreationDate,
         a.PostHistoryTypeId,
         ROW_NUMBER() OVER (PARTITION BY a.PostID ORDER BY a.CreationDate DESC) seq,
         b.Name
  FROM   PostHistory a
          INNER JOIN PostHistoryTypes b
            ON a.PostHistoryTypeId = b.Id
)
SELECT TOP 5000 a.*,
      b.Title,
      'http://stackoverflow.com/questions/' + CAST(b.ID AS VARCHAR(10)) AS QuestionLink
FROM   records a
      INNER JOIN Posts b
          ON b.Id = a.PostID
WHERE a.seq = 1 AND
      b.PostTypeId = 1

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results