Fork of Unused Templates by Zackmann08
This query is marked as a draft This query has been published by Zackmann08.

SQL

AخA
 
SELECT page_title, r.rev_timestamp
FROM page
LEFT JOIN revision r
    on r.rev_page = page.page_id
    AND r.rev_timestamp = (
      SELECT min(rev_timestamp) from revision
      where rev_page = page_id
    )
LEFT JOIN templatelinks t1
    ON t1.tl_namespace=10 AND t1.tl_title=page_title
LEFT JOIN logging_logindex
    ON log_type='create' AND log_namespace=10 AND log_title=page_title
WHERE page_namespace=10
    AND r.rev_timestamp < 20180101000000
    AND t1.tl_from IS NULL
    AND page_is_redirect=0
    AND page_title NOT LIKE '%/sandbox%'
    AND page_title NOT LIKE '%/testcases%'
    AND page_title NOT LIKE '%/doc%'
    AND page_title NOT LIKE '%stub'
    AND page_title NOT LIKE 'Attached_KML%'
    AND page_title NOT LIKE '%Did_you_know_nominations%'
    AND page_title NOT LIKE '%Editnotices%'
    AND NOT EXISTS (SELECT 1 FROM templatelinks t2
                    WHERE t2.tl_from=page_id
                        AND t2.tl_namespace=10
                        AND t2.tl_title IN ('Soft_redirect', 'Template_for_discussion/dated', 'Disambiguation', 'Link language/Notes' )
                    LIMIT 1)
    AND NOT EXISTS (SELECT 1 FROM categorylinks cl
                    WHERE cl.cl_from=page_id
                        AND cl.cl_to = "Wikipedia_substituted_templates"
                    LIMIT 1)
LIMIT 2000
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.

Checking query status...