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
Solidest
.
Toggle Highlighting
SQL
SELECT p.page_title AS template_name, COUNT(DISTINCT pl.pl_target_id) AS total_links, SUM(CASE WHEN p2.page_id IS NULL THEN 1 ELSE 0 END) AS red_links, ROUND(SUM(CASE WHEN p2.page_id IS NULL THEN 1 ELSE 0 END) * 100.0 / COUNT(DISTINCT pl.pl_target_id), 2) AS red_links_percentage FROM templatelinks tl JOIN page p ON tl.tl_from = p.page_id LEFT JOIN pagelinks pl ON pl.pl_from = tl.tl_from LEFT JOIN page p2 ON p2.page_id = pl.pl_target_id JOIN categorylinks cl ON cl.cl_from = p.page_id WHERE tl.tl_from_namespace = 10 -- Пространство имён шаблонов AND p.page_title NOT LIKE '%/doc' -- Исключаем документацию AND cl.cl_to LIKE 'Навигационные_шаблоны%' -- Только навигационные шаблоны AND pl.pl_from_namespace = 0 -- Только ссылки из основного пространства имен AND pl.pl_target_id IS NOT NULL -- Исключаем некорректные ссылки GROUP BY p.page_id, p.page_title HAVING total_links > 0 AND total_links < 1000 -- Разумное ограничение для производительности AND red_links = total_links ORDER BY total_links DESC LIMIT 100;
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...