Shows the ratio of answer votes to question votes in the last 50 weeks, clearly demonstrates the effects of the electorate badge
Q&A about the site for people interested in the history and origins of science and mathematics
-- Amount of Question Votes compared to Answer Votes -- Shows the ratio of answer votes to question votes in the last 50 weeks, clearly demonstrates the effects of the electorate badge /*set nocount on*/ declare @ranges table (id int identity, start datetime, finish datetime) declare @now datetime set @now = GetDate() insert @ranges select top 52 null,null from Posts update @ranges set start = DateAdd(ww,-1 - id,@now), finish = DateAdd(ww,0 - id, @now) set nocount off select start, sum(case when ParentId is null then 1 else 0 end)/ (sum(case when ParentId is null then 1 else 0 end) + sum(case when ParentId is not null then 1 else 0 end)+ 0.0) as ratio from votes join @ranges on CreationDate >= start and CreationDate < finish join Posts p on PostId = p.id where VoteTypeId = 2 group by start, finish order by start asc