Q&A for professional and enthusiast programmers
with editors as ( select userid, userid as [User Link], count(*) as "total edits", sum(rej) as rejected, sum(app) as approved, sum(app) * 100 / count(*) as "percentage approved" from (select owneruserid as userid, case when rejectiondate is null then 0 else 1 end as rej, case when approvaldate is null then 0 else 1 end as app from suggestededits) a group by userid ), thing as ( select top 20 * from editors order by userid ) select *, row_number() over(order by "total edits" asc) from thing