SELECT TOP 50000 p.Id AS id, REPLACE(p.Title, ',', ' ') A...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Music Fans

Q&A for music historians, critics, and fans

SELECT TOP 50000
      p.Id AS id,
      REPLACE(p.Title, ',', ' ') AS title,
      p.Tags AS tags,
      p.CreationDate AS creation_date, 
      p.LastActivityDate AS last_activity_date,
      ISNULL(p.FavoriteCount, 0) AS favourite_count, 
      ISNULL(p.ViewCount, 0) AS view_count,
      ISNULL(v.UpVote, 0) AS up_votes, 
      ISNULL(v.DownVote, 0) AS down_votes,
      p.Body AS body
FROM
(SELECT Votes.PostID, 
        UpVote = SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END), 
        DownVote = SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) 
        FROM Votes WHERE VoteTypeId in (2,3) GROUP BY PostId) v
RIGHT JOIN Posts p ON v.PostID = p.id
WHERE p.PostTypeId = 1
ORDER BY p.Id DESC

Enter Parameters

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