Q&A about the site for researchers and developers who explore the principles of a system through analysis of its structure, function, and operation
declare @question int = 1; declare @reTag int = 6; declare @initTag int = 3; declare @tagToSearch nvarchar(35) = ##tag:string?google-apps-script-simple-triggers##; SELECT FIRST_USER as [User Link], COUNT(PostId) AS 'COUNT', COUNT(PostId)*100/SUM(COUNT(PostId)) OVER () AS '%' FROM (select MAX(CreationDate) AS CDATE, PostId, FIRST_USER --,P.PostHistoryTypeId, --P.Text from (SELECT FIRST_VALUE(PH.UserId) OVER (PARTITION BY PH.PostId ORDER BY PH.CreationDate) AS FIRST_USER, * FROM PostHistory as PH WHERE (PH.PostHistoryTypeId = @reTag or PH.PostHistoryTypeId = @initTag ) and PH.Text like '%<' + @tagToSearch + '>%' ) AS P group by PostId,FIRST_USER --,P.PostHistoryTypeId,P.Text ) AS FULL_DATA GROUP BY FIRST_USER ORDER BY COUNT(PostId) desc