instruction: StackOverflow Rank and Percentile by Tag.
response: WITH Rankings AS (SELECT Id, Ranking = ROW_NUMBER() OVER (ORDER BY Reputation DESC) FROM Users WHERE UPPER(Users.Location) LIKE UPPER('##Country##')), Counts AS (SELECT Count = COUNT(*) FROM Users WHERE Reputation > '##ReputationCutoff##') SELECT Id, Ranking, 100 - (100 * (CAST(Ranking AS FLOAT(20, 5)) / (SELECT Count FROM Counts))) AS Percentile FROM Rankings WHERE Id = '##UserId##'