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


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

Switch sites:
loading Hold tight while we fetch your results