SELECT p1.id, p1.body, (SELECT TOP 1 p.Body FROM Posts p

0

Please login or register to vote for this query.

(click on this box to dismiss)

Lifehacks

Q&A for people looking to bypass life's everyday problems with simple tricks

--select * from posthistory where postid=284518


SELECT  p1.id, p1.body,
    (SELECT TOP 1 p.Body 
     FROM Posts p
     WHERE 
         p.PostTypeId = 2  -- 2 indica que é uma resposta
         AND p.ParentId = p1.Id  -- ID do post específico
     ORDER BY p.Score DESC) AS AnswerBody
FROM 
    Posts p1
WHERE 
    p1.Tags LIKE '%database%'
    AND p1.Tags LIKE '%artificial-intelligence%';
  
  
  /*SELECT top 1 
    p.Body AS AnswerBody,
  FROM 
    Posts p
WHERE 
    p.PostTypeId = 2  -- 2 indica que é uma resposta
    AND p.ParentId = p1.Id  -- ID do post específico
ORDER BY 
    p.Score DESC*\

Enter Parameters

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