Welcome Guest! To enable all features please
Login or Register.
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.
- Rank: YAF Commander
- Joined: 23/02/2008
- Posts: 74
- Thanks: 5 times
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
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
- 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.