create table #t (AnalisysDate datetime) declare @d date...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Emacs

Q&A for those using, extending or developing Emacs

-- Enter Query Title
-- Enter Query Description

create table #t (AnalisysDate datetime)

declare @d datetime
set @d = '2008-10-11'

while(@d<='2011-02-21')
begin
 insert into #t (AnalisysDate) values (@d)
 set @d = dateadd(day,1,@d)
end

--select * from #t order by AnalisysDate

select AnalisysDate, 
sum(
  case 
    when votetypeid = 2 then 1 
    when votetypeid = 3 then -1 
    else 0 
  end) as Score 
from      #t
left join votes v on creationdate=AnalisysDate
where     postid = 194812 and votetypeid in (2,3)
group by  AnalisysDate
order by  AnalisysDate asc

drop table #t

Enter Parameters

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