SELECT p.Id AS PostId, p.Title AS PostTitle, p.Body AS Po...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Psychology and Neuroscience

Q&A for practitioners, researchers, and students in cognitive science, psychology, neuroscience, and psychiatry

SELECT
    p.Id AS PostId,
    p.Title AS PostTitle,
    p.Body AS PostBody,
    p.Tags AS PostTags,
    p.OwnerUserId AS UserId,
    u.DisplayName AS UserName,
    u.Reputation AS ReputationScore
FROM (
    SELECT
        p.*,
        ROW_NUMBER() OVER (PARTITION BY p.OwnerUserId ORDER BY p.Id) AS RowNum
    FROM
        Posts p
    JOIN
        Users u ON p.OwnerUserId = u.Id
    JOIN
        Badges b ON u.Id = b.UserId
    WHERE
        b.Class = 3 -- Class 3 represents bronze badges
        AND YEAR(b.Date) BETWEEN 2018 AND 2019
        AND u.Reputation BETWEEN 1 AND 1000
        AND p.PostTypeId = 1 -- 1 represents questions
) AS Subquery
JOIN
    Posts p ON Subquery.Id = p.Id
JOIN
    Users u ON p.OwnerUserId = u.Id
WHERE
    Subquery.RowNum = 1;

Enter Parameters

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