Gold C# bearers' rank

1

Please login or register to vote for this query.

(click on this box to dismiss)

スタック・オーバーフロー

プログラマーとプログラミングに熱心な人々のための質問と回答

-- Tag Badge Linq

WITH data
     AS (SELECT Rank() OVER (PARTITION BY b.userid ORDER BY b.DATE) rn, 
                b.UserId, 
                b.Date
         FROM   badges b with (nolock)
         WHERE  b.name = 'c#') 
SELECT ROW_NUMBER() OVER (ORDER BY Date) as Number,
       u.DisplayName, 
       data.Date, 
       CASE rn 
         WHEN 1 THEN 'bronze' 
         WHEN 2 THEN 'silver' 
         WHEN 3 THEN 'gold' 
       END AS badge 
FROM data
     JOIN users u with (nolock) ON data.UserId = u.id 
where rn = 1
ORDER BY Date desc

Enter Parameters

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