YAFLogo

rai
  • rai
  • 100% (Exalted)
  • YAF Commander Topic Starter
4 years ago
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!

Sponsor

Zero2Cool
4 years ago
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
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
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