Bounty Amounts by quarter

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

select DATEPART(year, CreationDate) as [Year]
     , DATEPART(q, CreationDate) as [Quarter]
     , sum(case when BountyAmount <= 100 then 1 else 0 end) as [100]
     , sum(case when BountyAmount <= 200 
                     and BountyAmount > 100 then 1 else 0 end) as [200]
     , sum(case when BountyAmount <= 300 
                     and BountyAmount > 200 then 1 else 0 end) as [300]
     , sum(case when BountyAmount <= 400 
                     and BountyAmount > 300 then 1 else 0 end) as [400]
     , sum(case when BountyAmount <= 500 
                     and BountyAmount > 400 then 1 else 0 end) as [500]
     , sum(case when BountyAmount > 500 then 1 else 0 end) as [500+]
     , count(*)
  from Votes
 where BountyAmount is not null
 group by DATEPART(year, CreationDate)
        , DATEPART(q, CreationDate)
 order by DATEPART(year, CreationDate)
        , DATEPART(q, CreationDate)

Enter Parameters

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