select dateadd(wk, - datediff(wk, creationdate, getdate()...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Database Administrators

Q&A for database professionals who wish to improve their database skills and learn from others in the community

select dateadd(wk, - datediff(wk, creationdate, getdate()), getdate())
, sum( case when votetypeid = 2 then 1 else 0 end) up
, sum( case when votetypeid = 3 then 1 else 0 end) down
from votes 
group by datediff(wk, creationdate, getdate())
order by datediff(wk, creationdate, getdate())

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results