Toggle navigation
Home
New Query
Recent Queries
Discuss
Database tables
Database names
MediaWiki
Wikibase
Replicas browser and optimizer
Login
History
Fork
Fork of
wikidata: number of items per Q-ID bin
by
MisterSynergy
This query is marked as a draft
This query has been published
by
Mahir256
.
May be adjusted to count non-lonely items.
Toggle Highlighting
SQL
-- https://www.mediawiki.org/wiki/Manual:Database_layout -- note: the page table does not contain Q-IDs that have been deleted (or never been created) -- number of redirects: use WQS -- number of empty items: use WQS -- total number of item in bin: (rest may have been deleted, or never created) SELECT CEILING(SUBSTRING(page_title FROM 2) / 250000) AS bin, COUNT(*) AS cnt FROM page WHERE page_namespace=0 GROUP BY bin ORDER BY bin ASC; SELECT CEILING(ips_item_id / 250000) AS bin, COUNT(*) AS cnt FROM (SELECT ips_site_id, ips_item_id FROM wb_items_per_site GROUP BY ips_item_id HAVING COUNT(*)=1) items GROUP BY bin ORDER BY bin ASC; SELECT CEILING(ips_item_id / 250000) AS bin, COUNT(*) AS cnt FROM (SELECT ips_site_id, ips_item_id FROM wb_items_per_site GROUP BY ips_item_id HAVING COUNT(*)>1) items GROUP BY bin ORDER BY bin ASC; SELECT ips_site_id, COUNT(*) AS cnt FROM (SELECT ips_site_id, ips_item_id FROM wb_items_per_site GROUP BY ips_item_id HAVING COUNT(*)=1) items GROUP BY ips_site_id ORDER BY cnt DESC; -- number of items that have been deleted once (regardless of whether they have been restored): -- SELECT DISTINCT log_title FROM logging WHERE log_namespace=0 AND log_type='delete' -- pages that have been deleted, and not been restored -- SELECT DISTINCT log_title FROM logging WHERE log_namespace=0 AND log_type='delete' AND log_title NOT IN (SELECT page_title FROM page WHERE page_namespace=0) -- SELECT CEILING(SUBSTRING(log_title FROM 2) / 100000) AS bin, COUNT(*) AS cnt FROM logging WHERE log_namespace=0 AND log_type='delete' AND log_title NOT IN (SELECT page_title FROM page WHERE page_namespace=0) -- SELECT ?bin (COUNT(*) AS ?cnt) WHERE { -- #?item wikibase:statements 0 . -- #?item owl:sameAs [] . -- ?item wikibase:sitelinks [] . -- BIND(ceil(xsd:integer(SUBSTR(STR(?item),33)) / 100000) AS ?bin) . -- } GROUP BY ?bin ORDER BY ASC(?bin)
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...