Created
January 23, 2011 02:12
-
-
Save azcoov/791736 to your computer and use it in GitHub Desktop.
SQL Tag Cloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @MaxTagFrequency int | |
declare @tt_Tags table( | |
BlogCategory_ID int, | |
[Count] int | |
) | |
insert into | |
@tt_Tags | |
select top(@CountLimit) | |
bc.BlogCategory_ID, | |
count(bc.BlogCategory_ID) | |
from | |
BlogCategory bc | |
join BlogEntryCategory bec on bc.BlogCategory_ID = bec.BlogCategory_ID | |
group by | |
bc.BlogCategory_ID, | |
bc.Category | |
having count(bc.BlogCategory_ID) > 0 | |
select @MaxTagFrequency = max([Count]) from @tt_Tags | |
select | |
tt.BlogCategory_ID, | |
bc.Category, | |
tt.[Count], | |
convert(decimal(6,2),(convert(float,tt.[Count]) / convert(float,@MaxTagFrequency)) * 100) as [Weight] | |
from | |
@tt_Tags tt | |
join BlogCategory bc on tt.BlogCategory_ID = bc.BlogCategory_ID | |
order by | |
bc.Category |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment