1st task

0

Please login or register to vote for this query.

(click on this box to dismiss)

Vegetarianism Meta

Q&A about the site for those committed to a vegan or vegetarian lifestyle and anyone interested in learning more

select top 1 * from PostTags;
/*WITH YearlyTagCounts AS (
    SELECT TOP 5
        t.TagName
    FROM Posts p,
         PostTags pt,
         Tags t
    WHERE p.Id = pt.PostId
    AND pt.TagId = t.Id
    AND YEAR(p.CreationDate) = YEAR(GETDATE())
    GROUP BY t.TagName
    ORDER BY COUNT(p.Id) DESC
),
DailyTagPosts AS (
    SELECT
        p.CreationDate AS CDate,
        t.TagName,
        COUNT(p.Id) AS DailyPostCount
    FROM Posts p,
         PostTags pt,
         Tags t,
         YearlyTagCounts ytc
    WHERE p.Id = pt.PostId
    AND pt.TagId = t.Id
    AND t.TagName = ytc.TagName
    AND YEAR(p.CreationDate) = YEAR(GETDATE())
    GROUP BY p.CreationDate, t.TagName
),
CumulativeTagPosts AS (
    SELECT
        CDate,
        TagName,
        SUM(DailyPostCount) OVER (PARTITION BY TagName ORDER BY CDate ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS CumulativePosts
    FROM DailyTagPosts
)
SELECT
    CDate,
    TagName AS Theme,
    CumulativePosts AS CumulativeNumberOfPosts
FROM CumulativeTagPosts
ORDER BY TagName, CDate;*/

Enter Parameters

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