> Forums > Active Forums > Themes and Templates > Top 10 posters
Last Post 18 Mar 2012 06:05 AM by Adam Jones. 10 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Resolved
Mariette Knap
Customers
Mariette Knap
Post Count:645

--
09 Nov 2009 03:00 PM
    Hello,

    As I am preparing my site to move to AF 4.1 soon I also want to get my mini Top 10 users script working again. I am no SQL specialist so here is what I did:

    SELECT TOP 10 AuthorName AS Name , COUNT(*) AS Posts FROM dbo.activeforums_Content INNER JOIN Users ON UserID=AuthorId GROUP BY AuthorName ORDER BY COUNT(*) DESC

    This works well but I would to show 'Displayname' instead of 'Authorname'. I think I need to get that from the Users table but I have no ideas on how to do that

    <img src='http://www.activemodules.com/DesktopModules/ActiveForums/themes/activemodules/emoticons/wow.gif' align="absmiddle" border="0" />
    Mariëtte Knap
    www.smallbizserver.net
    Mariette Knap
    Customers
    Mariette Knap
    Post Count:645

    --
    15 Nov 2009 03:38 PM
    Bump...
    Mariëtte Knap
    www.smallbizserver.net
    Jason Peterson
    Customers
    Jason Peterson
    Post Count:525

    --
    15 Nov 2009 04:52 PM
    you have already joined to the user table, just change authorname to displayname in the 2 places it appears (select and group by) and you should be good.
    Jason Peterson
    Customers
    Jason Peterson
    Post Count:525

    --
    15 Nov 2009 04:55 PM
    • Accepted Answer
    SELECT TOP 10
    displayname AS Name ,
    COUNT(*) AS Posts
    FROM dbo.activeforums_Content
    INNER JOIN Users ON UserID=AuthorId
    GROUP BY displayname
    ORDER BY COUNT(*) DESC

    Query is above, you might consider only taking from the current week/month/3 months something rather than pulling from all time
    Mariette Knap
    Customers
    Mariette Knap
    Post Count:645

    --
    15 Nov 2009 05:25 PM
    • Accepted Answer
    Thanks. Now that is strange, the script gives me 12904 posts for myself but in AF is 12912...how can that happen?
    Mariëtte Knap
    www.smallbizserver.net
    Jason Peterson
    Customers
    Jason Peterson
    Post Count:525

    --
    15 Nov 2009 05:33 PM
    • Accepted Answer
    Sure np, the query has no criteria so it will pull anything, regardless of moderation and draft status. I am not sure what criteria the AF query is using but the difference is something with draft, moderation or similar.
    Will Morgenweck Forum Admin
    DotNetNuke Staff
    Will Morgenweck
    Post Count:7672

    --
    16 Nov 2009 02:48 PM
    Don't join on the content table. You just want the user, correct? Join on the activeforums_UserProfile table and Users table. All the numbers you want for the post counts are in the activeforums_UserProfile table.
    Will Morgenweck
    Director of Product Management
    DotNetNuke Corp.
    Jason Peterson
    Customers
    Jason Peterson
    Post Count:525

    --
    16 Nov 2009 07:01 PM
    Even better yet
    Mariette Knap
    Customers
    Mariette Knap
    Post Count:645

    --
    22 Nov 2009 03:11 AM
    This is my last version:

    SELECT TOP 10
    dbo.Users.DisplayName AS Name ,
    SUM(dbo.activeforums_UserProfiles.ReplyCount
    + dbo.activeforums_UserProfiles.TopicCount) AS Posts
    FROM dbo.activeforums_UserProfiles
    INNER JOIN USERS ON dbo.activeforums_UserProfiles.UserId = dbo.Users.UserID
    AND dbo.activeforums_UserProfiles.PortalId = '0'
    GROUP BY DisplayName
    ORDER BY Posts DESC
    Mariëtte Knap
    www.smallbizserver.net
    Adam Jones
    Customers
    Adam Jones
    Post Count:406

    --
    06 Jan 2010 11:29 PM
    Mariette, do you have an example of this somewhere?
    Adam Jones
    Customers
    Adam Jones
    Post Count:406

    --
    18 Mar 2012 06:05 AM
    SELECT TOP 10
    dbo.Users.DisplayName AS Name ,
    SUM(dbo.activeforums_UserProfiles.ReplyCount
    + dbo.activeforums_UserProfiles.TopicCount) AS Posts
    FROM dbo.activeforums_UserProfiles
    INNER JOIN USERS ON dbo.activeforums_UserProfiles.UserId = dbo.Users.UserID
    AND dbo.activeforums_UserProfiles.PortalId = &#39;0&#39;
    GROUP BY DisplayName
    ORDER BY Posts DESC  


    I got this working, but I also need to reference the USERID, can someone help modify this query.

    Right now its displaying DISPLAY NAME and # of POSTS. I just need it to also include the USER for the user.
    You are not authorized to post a reply.
    > Forums > Active Forums > Themes and Templates > Top 10 posters
    test
    Copyright 2012 by DotNetNuke Corporation / Terms of Use / Privacy