Retrieve data for here-api

1

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

DECLARE @TagId int = (
SELECT
  t.Id
FROM Tags t
WHERE t.TagName = ##TagName:string##
)

--DECLARE @OtherTagId int = (
--SELECT
--  t.Id
--FROM Tags t
--WHERE t.TagName = ##OtherTagName:string##
--)

DECLARE @UserId int = ##UserId## 

SELECT
  p.Id,
  CONCAT('site://q/', p.Id, '|', p.Title) AS [Post],
  p.CreationDate,
  p.Tags,
  p.Score,
  p.AnswerCount,
  p.CommentCount,
  CASE WHEN ISNULL(c.UserId,0) = 0 THEN 'No Comment' ELSE 'Commented' END AS Comment,
  CASE WHEN ISNULL(a.Id,0) = 0 THEN 'No Answer' WHEN ISNULL(a.OwnerUserId,0) = @UserId THEN  'Answered' ELSE 'Answered via Community' END AS Answer 
  FROM PostTags ptg
--JOIN PostTags otherTags ON otherTags.PostId = ptg.PostId
JOIN Posts p ON p.Id = ptg.PostId
LEFT JOIN Posts a ON a.ParentId = p.Id 
-- AND (a.OwnerUserId = @UserId OR a.OwnerUserId>0)
LEFT JOIN Comments c ON c.PostId = p.Id AND c.UserId = @UserId
WHERE ptg.TagId = @TagId 
AND p.CreationDate > DATEADD(day,-160,GETDATE()) 
 
--AND otherTags.TagId = @OtherTagId
-- GROUP BY p.Id

ORDER BY p.CreationDate ASC

-- TagName: Exact Name of Tag#1:
-- OtherTagName: Exact Name of Tag#2:
-- UserId : Enter the User ID

Enter Parameters

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