This is the first in a series of posts about getting some statistics for a .Text blog. I've been using the SQL below (and the SQL to come in subsequent posts) for several months now. When I first wrote this stuff, my original intent was to turn these into custom controls to plug into .Text and share the controls with everyone. However, I've never been able to set aside time to do that, and I won't for the foreseeable future. So I figured I should at least post the SQL statements that way anyone who has more time than me can maybe create the controls.
Some caveats to running these SQL statements. These were written for version 0.95.2004.102 of .Text and hasn't been tested with any other versions. And in order to actually run the SQL, you must have access to the database with all the .Text stored procedures (now you know why I wanted to turn these into controls - so everyone could benefit).
Without further ado, here's the SQL statement for getting the top 10 blog posts by number of web views. Just replace the value of the UserName to match your blog's virtual directory.
DECLARE @blogID int
/* Get blog ID */
SELECT @blogID = BlogID
FROM blog_Config
WHERE UserName = 'dave' /* Replace value here */
SELECT TOP 10
a.EntryID,
a.WebCount,
b.Title
FROM blog_EntryViewCount a JOIN blog_Content b
ON a.EntryID = b.[ID]
WHERE a.BlogID = @blogID AND b.PostConfig = 93
ORDER BY a.WebCount DESC
Print | posted on Tuesday, March 22, 2005 8:45 PM