Rarest (but existing) badge pairs

1

Please login or register to vote for this query.

(click on this box to dismiss)

Physical Fitness Meta

Q&A about the site for physical fitness professionals, athletes, trainers, and those providing health-related needs

WITH Raw AS (
  SELECT UserId, Name
  FROM Badges
  WHERE TagBased = 0
  GROUP BY UserId, Name
),
Raw2 AS (
  SELECT
    A.UserId,
    A.Name AS BadgeA,
    B.Name AS BadgeB
  FROM Raw A, Raw B
  WHERE
    A.UserId = B.UserId
    AND
    A.Name < B.Name
),
Raw3 AS (
  SELECT BadgeA, BadgeB, COUNT(*) AS Count
  FROM Raw2
  GROUP BY BadgeA, BadgeB
)
SELECT
  Raw3.Count,
  Raw2.BadgeA,
  Raw2.BadgeB,
  Raw2.UserId AS [User Link]
FROM Raw3, Raw2
WHERE
  Raw2.BadgeA = Raw3.BadgeA
  AND
  Raw2.BadgeB = Raw3.BadgeB
  AND
  Raw3.Count <= ##MaxCount:int?100##
ORDER BY Raw3.Count, Raw2.BadgeA, Raw2.BadgeB, Raw2.UserId

Enter Parameters

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