Retrieve data for here-api

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Different

Q&A for power users of Apple hardware and software

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## 
-- DECLARE @date  = ##FromDate:string## 


SELECT
-- Id of the post
  p.Id,
-- Post URL
  CONCAT('site://q/', p.Id, '|', p.Title) AS [Post],
-- Post Creation Date
  p.CreationDate,
-- Tags associated with post
  p.Tags,
-- Score associated with post
  p.Score,
-- Number of answers provided
  p.AnswerCount,
-- Number of comments provided
  p.CommentCount,
-- User name of Answer provider
  u.DisplayName as AnsweredBy,
-- Commented by Developer Support or not
  CASE WHEN ISNULL(c.UserId,0) = 0 THEN 'No Comment' ELSE 'Commented' END AS Comment,
-- Answered or not
  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 
LEFT JOIN Users u ON u.Id = a.OwnerUserId

-- 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 
-- Post after date '2021-01-01'
AND p.CreationDate > COALESCE(TRY_CONVERT(date, '2021-01-01', 111), '2021-01-01')
-- DATEADD(day,-190,GETDATE()) 
 
--AND otherTags.TagId = @OtherTagId
-- GROUP BY p.Id

ORDER BY p.CreationDate ASC

-- TagName: Exact Name of Tag#1: e.g. here-api
-- FromDate: Enter From Date : 
-- UserId : Enter the User ID : e.g. 3505695

Enter Parameters

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