Usage of Stack Snippets in Correct Tags

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @totalSnippets int;
DECLARE @totalSnippetsInTags int;
DECLARE @totalSnippetsBadTags int;

SELECT Id, Tags, Title, Body
INTO #tmp
FROM POSTS
WHERE PostTypeId IN(1)
       AND CreationDate > '2014-06-01'  
       AND Body LIKE('%div class="snippet"%')

SELECT @totalSnippets = COUNT(1) 
FROM #tmp

SELECT @totalSnippetsInTags = COUNT(1) 
FROM #tmp
where tags like('%javascript%') or
      tags like('%html%') or 
      tags like('%css%') or
      tags like('%js%') or 
      tags like('%jquery%')
       
SELECT @totalSnippetsBadTags = COUNT(1) 
FROM #tmp
WHERE tags not like('%javascript%') and 
      tags not like('%html%') and 
      tags not like('%css%') and
      tags not like('%js%') and 
      tags not like('%jquery%')

SELECT @totalSnippets as TotalSnippets, 
       @totalSnippetsInTags as TotalSnippetsInTags,
       @totalSnippetsBadTags as TotalSnippetsBadTags
       
-- Uncomment Below for examples of bad snippets
--SELECT *
--FROM #tmp
--WHERE tags not like('%javascript%') and 
--      tags not like('%html%') and 
--      tags not like('%css%') and
--      tags not like('%js%') and 
--      tags not like('%jquery%')

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results