Quickest Badge Earners (v1.0)

0

Please login or register to vote for this query.

(click on this box to dismiss)

Science Fiction and Fantasy

Q&A for science fiction and fantasy enthusiasts

--A short revamp of polygenelubricants' "Quickest badge earners V2c" since I am unable to figure out why it is not
--returning for some badges.
--OG: https://data.stackexchange.com/stackoverflow/query/10418/quickest-badge-earners-v2c
DECLARE @firsttime DATE
SELECT @firsttime = MIN(Badges.DATE) FROM Badges WHERE Badges.Id = 6381
;
WITH BadgeEarners AS(
  SELECT
    Users.Id AS [User Link],
    Users.CreationDate AS [Member Since],
    Badges.DATE AS [Date Won],
    1+DATEDIFF(DAY,Users.CreationDate,Badges.DATE) AS [Days Membership]
   FROM Badges
   INNER JOIN Users ON Badges.UserId = Users.Id
   WHERE Badges.Id = 6381
   )
SELECT *,DATEDIFF(DAY,@firsttime,[Date Won]) AS [DaysSince1st]
FROM BadgeEarners
ORDER BY [Date Won] ASC

Enter Parameters

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