Most Upvoted Questions

0

Please login or register to vote for this query.

(click on this box to dismiss)

The top 20 questions with the most up-votes (ignores down-votes)

Sports

Q&A for participants in team and individual sport activities

-- Most Upvoted and Popular Questions
-- The top 20 questions with the most up-votes (ignores down-votes)
SELECT
  Q.Id
  , Q.Title
  , Q.ViewCount
  , 'http://stackoverflow.com/questions/' + Cast(Q.Id AS VARCHAR(10))  AS QuestionLink
  , Q.Tags
  , (LEN(A.Body) - LEN(REPLACE(A.Body, '<pre><code>', '')))/LEN('<pre><code>') AS CodeSections
  , SUBSTRING (A.Body, CHARINDEX('<pre><code>',A.Body), CHARINDEX('</code></pre>',A.Body)) AS Codetext
  , A.Body AS AnswerBody
FROM (
SELECT TOP 50000
  V.PostId AS Id,
  COUNT(V.PostId) AS VoteCount, 
  V.PostId AS [Post Link],
  P.Title,
  P.Body, 
  P.ViewCount, 
  P.Tags,
  P.OwnerUserId,
  P.AcceptedAnswerId
FROM Votes V 
INNER JOIN Posts P 
  ON P.Id = V.PostId
INNER JOIN posttags AS PT 
  ON PT.PostId = P.Id
WHERE P.PostTypeId = 1 and VoteTypeId=2
  AND PT.TagId = 17 -- <<== JAVA
  OR PT.TagId = 1386 -- <<== ANDROID
  AND P.AcceptedAnswerId IS NOT NULL -- <<== question has accepted answer
GROUP BY 
  V.PostId,
  P.Title,
  P.Body, 
  P.ViewCount,
  P.Tags,
  P.OwnerUserId,
  P.AcceptedAnswerId
--order by 'Vote count' desc
ORDER BY P.ViewCount DESC
) AS Q
INNER JOIN Posts AS A
 ON A.PostTypeId = 2 -- <<== Answer
 AND Q.Id = A.ParentId
 AND Q.OwnerUserId <> A.OwnerUserId
 AND Q.AcceptedAnswerId = A.Id
 AND A.AcceptedAnswerId IS NULL
WHERE Charindex('<pre><code>', A.body) > 0
  AND (LEN(A.Body) - LEN(REPLACE(A.Body, '<pre><code>', '')))/LEN('<pre><code>') = 1
  AND LEN('<pre><code>') >= 10

ORDER BY Q.ViewCount DESC

Enter Parameters

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