WITH RankedQuestions AS ( SELECT q.Id AS QuestionId, q.Ti...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow Meta en español

Preguntas y respuestas sobre el sitio para programadores y profesionales de la informática

WITH RankedQuestions AS (
  SELECT
    q.Id AS QuestionId,
    q.Title AS Question_Title,
    q.Body AS Question_Body,
    q.Tags AS Question_Tags,
    q.CreationDate AS Question_CreationDate,
    q.Score AS Question_Score,
    a.Id AS AnswerId,
    a.Body AS Answer_Body,
    a.CreationDate AS Answer_CreationDate,
    a.Score AS Answer_Score,
    RANK() OVER (PARTITION BY q.Id ORDER BY a.Score DESC) AS AnswerRank
  FROM
    Posts q
  JOIN
    Posts a ON q.Id = a.ParentId
  WHERE
    (q.Tags LIKE '%<java>%')
    AND (q.PostTypeId = 1) -- 1 for questions
)
SELECT
  QuestionId AS [Question Link],
  AnswerId AS [Answer Link],
  Question_Title,
  Question_Body,
  Question_Tags,
  Question_CreationDate,
  Question_Score,
  Answer_Body,
  Answer_CreationDate,
  Answer_Score
FROM
  RankedQuestions
WHERE
  AnswerRank = 1 -- Select the top answer for each question
ORDER BY
  Question_Score DESC, Question_CreationDate DESC; -- Order by the question score and creation date

Enter Parameters

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