DECLARE @Average int
DECLARE @Items TABLE ([Post Link] int, Score int, ViewCount int, Url string)
INSERT INTO @Items ([Post Link], Score, ViewCount, Url)
SELECT p.Id AS [Post Link], p.Score, p.ViewCount,
'site://questions/tagged/' + CAST(TagName AS VARCHAR) + '?sort=active' AS Url
FROM Posts p
INNER JOIN Tags t
ON LCASE(p.Title) LIKE '%' + t.TagName + '%'
WHERE PostTypeId = 1
AND ClosedDate IS NULL
AND
NOT p.Tags LIKE '%status-completed%'
AND Score >= 0