Fork of Templates with link and redlink counts by Certes
This query is marked as a draft This query has been published by Qwerfjkl.

SQL

AخA
 
SELECT Pt.page_title, COUNT(*) links, SUM(CASE WHEN Pa.page_title IS NULL THEN 1 ELSE 0 END) redlinks
FROM pagelinks
/* JOIN page Pt ON Pt.page_id = pl_from */
LEFT JOIN page Pa ON Pa.page_title = pl_title AND Pa.page_namespace = 0
JOIN page Pt ON Pt.page_id = pl_from
WHERE pl_from_namespace = 10 AND pl_namespace = 0 /* Template→Article links only */
GROUP BY Pt.page_title WITH ROLLUP
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.

This query has never yet been executed