Q&A for gardeners and landscapers
declare @country nvarchar(100) set @country = ##country:string?Romania## set @country = '%'+ @country +'%' select owneruserid as [User Link] , row_number() over(order by rep desc) as ranking , rep from ( select p.owneruserid ,sum(case v.votetypeid when 2 then -- upvote case p.posttypeid when 1 then 5 -- Q else 10 end -- A else 0 end) + sum(case v.votetypeid when 3 then -2 else 0 end) -- downvote + sum(case v.votetypeid when 1 then 15 else 0 end) as rep -- accept from posts p inner join votes v on v.postid = p.id inner join users u on u.id = p.owneruserid where v.votetypeid in (1,2,3) and p.owneruserid is not null and u.location like @country collate SQL_Latin1_General_CP1_CI_AI group by p.owneruserid ) as rawdata order by ranking