Q&A about the site for road warriors and seasoned travelers
select top 800 user_id, 'Week2' As week, sum(Num_of_Records) as Num_of_Records, sum( Num_of_Records*(case when PostTypeId = 1 AND VoteTypeId = 2 THEN 5 when PostTypeId = 1 AND VoteTypeId = 3 THEN -2 when PostTypeId = 2 AND VoteTypeId = 2 THEN 10 when PostTypeId = 2 AND VoteTypeId = 3 THEN -2 end)) As "Line_rep" from ( select COUNT(*) As "Num_of_Records", Users.Id As "user_id",Reputation,VoteTypeId, Posts.PostTypeId, Votes.CreationDate from Users inner join Posts on Users.id = Posts.OwnerUserId inner join Votes on Posts.id = Votes.PostId where Votes.CreationDate between '2010-01-11' and '2010-01-17' AND Posts.PostTypeId IN (1,2) AND VoteTypeId IN (2,3) group by Users.Id,Reputation,VoteTypeId, Posts.PostTypeId, Votes.CreationDate --order by Users.Id ) new1 group by user_id order by sum( Num_of_Records*(case when PostTypeId = 1 AND VoteTypeId = 2 THEN 5 when PostTypeId = 1 AND VoteTypeId = 3 THEN -2 when PostTypeId = 2 AND VoteTypeId = 2 THEN 10 when PostTypeId = 2 AND VoteTypeId = 3 THEN -2 end)) DESC