Toggle navigation
Home
New Query
Recent Queries
Discuss
Database tables
Database names
MediaWiki
Wikibase
Replicas browser and optimizer
Login
History
Fork
This query is marked as a draft
This query has been published
by
MohanReddy15
.
Compare each top editor's total edits against the overall average: How much more than average as percentage
Toggle Highlighting
SQL
SET @Average_edits = ( SELECT AVG(Total_edits) AS Average_edits FROM ( SELECT r.rev_actor AS EDITOR_ID, a.actor_name, COUNT(r.rev_id) AS TOTAL_EDITS FROM revision AS r JOIN actor AS a ON r.rev_actor = a.actor_id WHERE r.rev_timestamp BETWEEN DATE_FORMAT(CURDATE() - INTERVAL 2 MONTH, '%Y-%m-01') AND LAST_DAY(CURDATE()) GROUP BY r.rev_actor ) AS NEW ); SELECT a.actor_name AS EDITOR_NAME, COUNT(r.rev_id) AS TOTAL_EDITS, ROUND(((COUNT(r.rev_id) - @Average_edits) / @Average_edits) * 100) AS PERCENTAGE FROM revision AS r JOIN actor AS a ON r.rev_actor = a.actor_id WHERE r.rev_timestamp BETWEEN DATE_FORMAT(CURDATE() - INTERVAL 2 MONTH, '%Y-%m-01') AND LAST_DAY(CURDATE()) GROUP BY EDITOR_NAME ORDER BY Total_edits DESC LIMIT 5;SET @Average_edits = ( SELECT AVG(Total_edits) AS Average_edits FROM ( SELECT r.rev_actor AS EDITOR_ID, a.actor_name, COUNT(r.rev_id) AS TOTAL_EDITS FROM revision AS r JOIN actor AS a ON r.rev_actor = a.actor_id WHERE r.rev_timestamp BETWEEN DATE_FORMAT(CURDATE() - INTERVAL 2 MONTH, '%Y-%m-01') AND LAST_DAY(CURDATE()) GROUP BY r.rev_actor ) AS NEW ); SELECT a.actor_name AS EDITOR_NAME, COUNT(r.rev_id) AS TOTAL_EDITS, ROUND(((COUNT(r.rev_id) - @Average_edits) / @Average_edits) * 100) AS PERCENTAGE FROM revision AS r JOIN actor AS a ON r.rev_actor = a.actor_id WHERE r.rev_timestamp BETWEEN DATE_FORMAT(CURDATE() - INTERVAL 2 MONTH, '%Y-%m-01') AND LAST_DAY(CURDATE()) GROUP BY EDITOR_NAME ORDER BY Total_edits DESC LIMIT 5;
By running queries you agree to the
Cloud Services Terms of Use
and you irrevocably agree to release your SQL under
CC0 License
.
Submit Query
Stop Query
All SQL code is licensed under
CC0 License
.
Checking query status...