Banned Users

0

Please login or register to vote for this query.

(click on this box to dismiss)

Drupal Answers Meta

Q&A about the site for Drupal developers and administrators

DECLARE @StartDate DATETIME = '2024-05-06';
DECLARE @EndDate DATETIME = '2024-06-01';

-- Step 1: Filter users by reputation and last access date
WITH FilteredUsers AS (
    SELECT
        u.Id AS [UserId],
        u.DisplayName AS [UserName],
        u.Reputation,
        u.UpVotes,
        u.DownVotes,
        u.LastAccessDate
    FROM
        Users u
    WHERE
        u.Reputation = 1
        AND u.LastAccessDate BETWEEN @StartDate AND @EndDate
)

-- Step 2: Calculate the sum of post scores for filtered users
SELECT
    fu.UserId,
    fu.UserName,
    fu.LastAccessDate,
    SUM(p.Score) AS TotalScore
FROM
    FilteredUsers fu
    INNER JOIN Posts p ON fu.UserId = p.OwnerUserId
GROUP BY
    fu.UserId,
    fu.UserName,
    fu.UpVotes,
    fu.DownVotes,
    fu.LastAccessDate
HAVING
    SUM(p.Score) > 0
ORDER BY
    fu.LastAccessDate DESC;

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results