Q&A for SharePoint enthusiasts
DECLARE @StartTime DATETIME2 = SYSDATETIME(); -- Your query here SELECT TagName, AVG(UpVoteCount) as AvgUpVote FROM ( SELECT Pos.Id, Tag.TagName, CAST(COUNT(1) AS Decimal(10, 4)) AS UpVoteCount FROM Posts AS Pos INNER JOIN Users AS Usr ON Usr.Id = Pos.OwnerUserId AND UPPER(Usr.Location) LIKE '%LATVI%' INNER JOIN PostTags AS PosTg ON PosTg.PostId = Pos.Id INNER JOIN Tags AS Tag ON PosTg.TagId = Tag.Id AND (UPPER(Tag.TagName) = 'SQL' OR UPPER(Tag.TagName) = 'MYSQL') INNER JOIN Votes AS Vte ON Vte.PostId = Pos.Id INNER JOIN VoteTypes AS VteTyp ON Vte.VoteTypeId = VteTyp.Id AND VteTyp.Name = 'UpMod' GROUP BY Tag.TagName, Pos.Id ) AS PostSubQr GROUP BY TagName; DECLARE @EndTime DATETIME2 = SYSDATETIME(); SELECT DATEDIFF(SECOND, @StartTime, @EndTime) AS ExecutionTimeInSeconds;