Skip to content

Instantly share code, notes, and snippets.

@chrisdavies
Created February 1, 2012 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdavies/1719912 to your computer and use it in GitHub Desktop.
Save chrisdavies/1719912 to your computer and use it in GitHub Desktop.
Count the number of silver, gold, platinum, and unique recipients of awards in the Sparcet system.
Select
FromUserId,
Count(case when AwardType = 0 then 1 end) as silver,
Count(case when AwardType = 1 then 1 end) as gold,
Count(case when AwardType = 2 then 1 end) as plat,
Count(distinct ToUserId) as [unique],
Count(*) as total
From
Awards
Group By FromUserId;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment