#1
Can somebody help me with creating a query that is grouping number of Thanks by email. I would like to reward the most thanked users so I need to generate a list.

Thanks!

Topic Starter
  • rai
  • Rank: YAF Commander
  • Reputation:
    Exalted
    99.2%
  • Joined: 23/02/2008
  • Posts: 74
  • Thanks: 5 times
#2
Here's what I use to get the most X thanks by userID for the last 7 days. Just remove the where clause and well whatever ya want. This should help you get going.

DECLARE @Topper INT = @Top
   
   SELECT TOP (@Topper) yaf_User.UserID, yaf_User.Name, COUNT(ThanksToUserID) as Total
   FROM yaf_Thanks 
   INNER JOIN yaf_User 
   ON yaf_Thanks.ThanksToUserID = yaf_User.UserID 
   INNER JOIN yaf_Message
   ON yaf_Message.MessageID = yaf_Thanks.MessageID
   INNER JOIN yaf_Topic
   ON yaf_Topic.TopicID = yaf_Message.TopicID
   WHERE yaf_Thanks.ThanksDate > DATEADD(DAY, -7, GETDATE()) 
   GROUP BY yaf_Thanks.ThanksToUserID, yaf_User.Name, yaf_user.UserID
   ORDER BY COUNT(ThanksToUserID) DESC
  • Zero2Cool
  • Rank: YAF Leader
  • Reputation:
    Exalted
    100%
  • Medals:
    Medal of Honor for the Support Knight: Given to a community member who has assisted lots and lots of people!
  • Joined: 26/04/2011
  • Posts: 1,071
  •  Man  United States
  • Location: in a van down by the river
  • Thanks: 239 times
  • Was thanked: 101 time(s) in 92 post(s)
Users browsing this topic

Forum Jump  
  • You cannot post new topics in this forum.
  • You cannot reply to topics in this forum.
  • You cannot delete your posts in this forum.
  • You cannot edit your posts in this forum.
  • You cannot create polls in this forum.
  • You cannot vote in polls in this forum.

About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button

Project Twitter Updates

Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved