Tag Addition Stats

1

Please login or register to vote for this query.

(click on this box to dismiss)

Bicycles Meta

Q&A about the site for people who build and repair bicycles, people who train cycling, or commute on bicycles

declare @TagName nvarchar(35) = ##TagName:string##;

SELECT
    NumberOfAdditions,
    TotalNewPosts,
    FORMAT(CAST(NumberOfAdditions AS DECIMAL(10, 0)) / CAST(TotalNewPosts AS DECIMAL(10, 0)),
           'P3') AS PercentAdded
    FROM (
         SELECT
             SUM(IIF(orig.Text NOT LIKE '%<' + @TagName + '>%', 1, 0)) AS NumberOfAdditions,
             COUNT(*) AS TotalNewPosts
             FROM PostHistory orig
                 INNER JOIN
             PostHistory new ON orig.PostId = new.PostId AND new.CreationDate > orig.CreationDate
             WHERE (orig.PostHistoryTypeId = 3 OR orig.PostHistoryTypeId = 6)
               AND new.PostHistoryTypeId = 6
               AND new.Text LIKE '%<' + @TagName + '>%'
         ) as RemovalData

Enter Parameters

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