SQL
x
SET @yr='1908_births';
WITH results AS
(SELECT COUNT(rev_page) AS pages, actor_name AS creator
FROM actor_revision
JOIN revision ON rev_actor = actor_id
WHERE rev_id IN
(SELECT MIN(rev_id)
FROM revision
WHERE rev_page IN
(SELECT DISTINCT birth.cl_from
FROM categorylinks AS birth
JOIN categorylinks AS stub ON stub.cl_from = birth.cl_from
JOIN categorylinks AS olym ON olym.cl_from = birth.cl_from
WHERE birth.cl_to = @yr
AND stub.cl_to = 'All_stub_articles'
AND olym.cl_to LIKE '%Olympi%')
GROUP BY rev_page)
GROUP BY actor_name)
SELECT SUM(pages) AS pages, 'TOTAL' AS creator FROM results
UNION
SELECT * FROM results ORDER BY pages DESC, creator ASC;
By running queries you agree to the Cloud Services Terms of Use and you irrevocably agree to release your SQL under CC0 License.
All SQL code is licensed under CC0 License.