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
Zero0000
.
Toggle Highlighting
SQL
set @reverted = 590; set @undo = 1; set @rollback = 8; with pia_titles as ( select p.page_title from linktarget lt join templatelinks tl on tl.tl_target_id = lt.lt_id join page p on p.page_id = tl.tl_from where lt.lt_namespace = 10 -- Template and lt.lt_title in ("ArbCom_Arab-Israeli_enforcement", "Contentious_topics/Arab-Israeli_talk_notice") and page_namespace = 1 and page_is_redirect = 0 union select page_title from page join categorylinks israel on page_id = israel.cl_from and israel.cl_to = "WikiProject_Israel_articles" join categorylinks palestine on page_id = palestine.cl_from and palestine.cl_to = "WikiProject_Palestine_articles" where page_namespace = 1 and page_is_redirect = 0 ), pia as ( -- add required page_namespace values here. can only match on page_title -- unioning separate selects for each namespace seems to be faster than doing 'in (0,1,...)' for large queries with thousands of actors. select p1.page_id, p1.page_title, p1.page_namespace from pia_titles pt join page p1 on p1.page_title = pt.page_title and p1.page_namespace in (0,1) and p1.page_is_redirect = 0 join revision_userindex as r on r.rev_page = p1.page_id ), pia_final as ( select 'PIA' area, pia.page_namespace, count(r.rev_id) AS rev_count, SUM(CASE WHEN ct.ct_tag_id = @reverted THEN 1 ELSE 0 END) AS reverted, SUM(CASE WHEN ct.ct_tag_id in (@undo,@rollback) THEN 1 ELSE 0 END) AS reverts, SUM(CASE WHEN ct.ct_tag_id in (@undo,@rollback) AND EXISTS ( SELECT 1 FROM change_tag AS ct_inner WHERE ct_inner.ct_tag_id = @reverted AND ct_inner.ct_id = ct.ct_id ) THEN 1 ELSE 0 END) AS reverts_reverted -- from revision_userindex as r from pia -- pia on pia.page_id = r.rev_page left join change_tag as ct ON pia.rev_id = ct.ct_rev_id -- left join change_tag_def AS ctd ON ct.ct_tag_id = ctd.ctd_id where date(pia.rev_timestamp) BETWEEN '2023-10-07' AND '2024-10-06' group by page_namespace ) select page_namespace, rev_count, reverts, ROUND(100.0 * reverts/rev_count,2) as percent_reverts, reverted, ROUND(100.0 * reverted/rev_count,2) as percent_reverted, reverts_reverted from pia_final order by page_namespace,rev_count desc
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...