最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

sql - To query the number of users per tag in Stack Exchange Data Explorer (SEDE) - Stack Overflow

programmeradmin1浏览0评论

Find all question posts with the tag ‘python’ on stack overflow, along with all their replies and comments, including the user who posted the question and reply, and then assign these posts to the corresponding year and month based on when they were posted to calculate the number of relevant users for each month and year, where relevant users are the users who posted the question and reply. users. Below is my code, after running the result is empty, can you help me point out the problem and the correct code?

SELECT
    DATEPART(yyyy, p.CreationDate) AS Year,
    DATEPART(mm, p.CreationDate) AS Month,
    COUNT(DISTINCT CASE WHEN p.PostTypeId = 1 THEN p.OwnerUserId ELSE NULL END) AS Questioning,
    COUNT(DISTINCT CASE WHEN p.PostTypeId = 2 THEN p.OwnerUserId ELSE NULL END) AS Answering,
    COUNT(DISTINCT p.OwnerUserId) AS RelevantUsers
FROM
    Posts p
JOIN
    PostTags pt ON p.Id = pt.PostId OR p.ParentId = pt.PostId
JOIN
    Tags t ON pt.TagId = t.Id
WHERE
    t.TagName = 'python'
GROUP BY
    DATEPART(yyyy, p.CreationDate),
    DATEPART(mm, p.CreationDate)
ORDER BY
    Year, Month;
发布评论

评论列表(0)

  1. 暂无评论