WITH allData AS ( SELECT ROW_NUMBER() OVER (ORDER BY u.Di...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- StartRow: Starting row for paging
-- EndRow: Ending row for paging (Max 50K rows at a time)
-- MinimumRep: Ony return data for users that have this many reputation points
WITH allData AS (
    SELECT
                ROW_NUMBER() OVER (ORDER BY u.Displayname, b.Date DESC) AS row
                , u.Id
                , CASE
                    WHEN b.Tagbased = 1 THEN 'Tag: [' + b.Name + ']'
                    ELSE b.Name
                END    AS [Badge name]
                , CASE
                    WHEN b.Class = 1 THEN 'Gold'
                    WHEN b.Class = 2 THEN 'Silver'
                    WHEN b.Class = 3 THEN 'Bronze'
                    ELSE '*Unkown*'
                END    AS [Class]
                , b.Date AS [Awarded]
    FROM        Users u
    INNER JOIN  Badges b    ON u.Id = b.Userid
    WHERE       u.reputation > ##MinimumRep:int?100000##
)
SELECT      a.Id     AS [User Link]
            , a.[Badge name]
            , a.[Class]
            , a.[Awarded]
FROM        allData a
WHERE       row    >= ##StartRow:INT?1##
AND         row    <= ##EndRow:INT?50000##
ORDER BY    row

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results