Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

This challenge involves counting the number of occurrences of HTML tags in a given list of strings. You can assume that there will be only valid HTML tags in the input strings. The output should display tags in ascending order.

TSQL Beginners Challenge 18 - Count the total occurrences of HTML tags in the given string

Solution to TSQL Beginners Challenge 18

Aug 5 2011 7:37AM by Adam Tokarski   

Solution to TSQL Beginners Challenge 18

;WITH HtmlTable(Id, Tag)
AS 
(
	SELECT t.Id, substring(t.HtmlText, tally.N+1, charindex('>',t.HtmlText, tally.N)-tally.N-1)
	FROM @t t, ufn_Tally2(1, 8000,1) tally 
	WHERE substring(t.HtmlText, Tally.N, 1) = '<'
	AND substring(t.HtmlText, Tally.N+1, 1) <> '/'

)
,ResTable2(Id, Tag, TagCount)
AS
(
	SELECT Id, Tag, COUNT(*) FROM HtmlTable GROUP BY Id, Tag
)
,ResTable(Id, TagString)
AS
(
	SELECT DISTINCT Id, (SELECT ', ' + HT.Tag+'(Found: '+CAST(HT.TagCount AS VARCHAR(10))+' time'+(CASE WHEN HT.TagCount=1 THEN ')' ELSE 's)' END)
	FROM ResTable2 HT WHERE HT.Id = _HT.Id FOR XML PATH(''))X FROM ResTable2 _HT 
)
SELECT ID, STUFF(TagString, 1, 2, '') [TagNamesOccurance] FROM ResTable
ORDER BY Id

Tags:


Adam Tokarski
58 · 3% · 1021
0
Liked



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]