title
stringlengths
1
212
description
stringlengths
1
4.39k
query
stringlengths
1
65.5k
extra_info
stringlengths
18
31.6k
wikidb
stringlengths
4
26
Last 50 GWToolset uploads
Most recent files uploaded by the GLAMwikiToolset
use commonswiki_p; SELECT page.page_title, categorylinks.cl_timestamp as timestamp FROM page JOIN categorylinks ON page.page_id = categorylinks.cl_from WHERE categorylinks.cl_to = 'GWToolset_Batch_Upload' AND categorylinks.cl_type = "file" ORDER BY categorylinks.cl_timestamp ASC LIMIT 50;
{"resultsets": [{"headers": ["page_title", "timestamp"], "rowcount": 50}]}
null
Learning patterns created per month
Learning patterns created per month. Note: Patterns will only show up on this list if they still exist and are still categorized as such. Last run on 9/17/2014
#count Learning Patterns created per month SELECT EXTRACT(YEAR FROM DATE_FORMAT(rev_timestamp,'%Y%m%d%H%i%s')) AS `year`, EXTRACT(MONTH FROM DATE_FORMAT(rev_timestamp,'%Y%m%d%H%i%s')) AS `month`, COUNT(rev_id) AS patterns_created FROM metawiki_p.revision r INNER JOIN metawiki_p.page AS p ON r.rev_page = p.page_id INNER JOIN metawiki_p.categorylinks AS cl ON p.page_id = cl.cl_from WHERE p.page_namespace = 200 AND cl.cl_to IN ("Learning_patterns") AND r.rev_parent_id = 0 GROUP BY `year`, `month` ORDER BY `year` ASC, `month` ASC;
{"resultsets": [{"headers": ["year", "month", "patterns_created"], "rowcount": 15}]}
null
Learning patterns by creation date
Learning patterns by the date they were created. Note: Pages will only show up on this list if they still exist and are still categorized as patterns. Last run on 9/17/2014
#list Learning patterns by creation date SELECT page_title, rev_id, rev_timestamp, rev_comment, rev_user_text FROM metawiki_p.page p INNER JOIN metawiki_p.categorylinks cl ON p.page_id = cl.cl_from INNER JOIN metawiki_p.revision r ON p.page_id = r.rev_page WHERE p.page_namespace = 200 AND cl.cl_to IN ("Learning_patterns") AND r.rev_parent_id = 0 ORDER BY rev_timestamp DESC;
{"resultsets": [{"headers": ["page_title", "rev_id", "rev_timestamp", "rev_comment", "rev_user_text"], "rowcount": 97}]}
null
Active new editors on Swedish Wikipedia
“get me every new account on Swedish Wikipedia that has been created within the past week, has made at least 10 edits, is not a bot, and has not been blocked yet”
SELECT user_name FROM commonswiki_p.user WHERE user_name like '%(SLU)'
{"resultsets": [{"headers": ["user_name"], "rowcount": 81}]}
null
Mean lifetime of reverted revision in featured articles @ ptwiki
null
use ptwiki_p; select avg(HOUR(TIMEDIFF(CAST(r.rev_timestamp AS DATETIME),CAST(rp.rev_timestamp AS DATETIME)))), EXTRACT(MONTH FROM CAST(r.rev_timestamp AS DATETIME)) AS MES, EXTRACT(YEAR FROM CAST(r.rev_timestamp AS DATETIME)) AS ANO FROM revision r INNER JOIN revision rp ON r.rev_parent_id = rp.rev_id INNER JOIN revision rpp ON rp.rev_parent_id = rpp.rev_id WHERE r.rev_timestamp > 20140000000000 and r.rev_sha1 = rpp.rev_sha1 and r.rev_page IN (select distinct cl_from from categorylinks where cl_to = "!Artigos_destacados") GROUP BY 2,3 ORDER BY 3,2 ;
{"resultsets": [{"headers": ["avg(HOUR(TIMEDIFF(CAST(r.rev_timestamp AS DATETIME),CAST(rp.rev_timestamp AS DATETIME))))", "MES", "ANO"], "rowcount": 9}]}
null
Get nlwiki page schema
null
DESCRIBE nlwiki_p.page;
{"resultsets": [{"headers": ["Field", "Type", "Null", "Key", "Default", "Extra"], "rowcount": 14}]}
null
Get data of nlwiki's 1,000,000th article
null
SELECT * FROM nlwiki_p.page WHERE page_id = 2690956;
{"resultsets": [{"headers": ["page_id", "page_namespace", "page_title", "page_restrictions", "page_counter", "page_is_redirect", "page_is_new", "page_random", "page_touched", "page_links_updated", "page_latest", "page_len", "page_no_title_convert", "page_content_model"], "rowcount": 1}]}
null
Secret query. No looking.
null
SELECT "LOL";
{"resultsets": [{"headers": ["LOL"], "rowcount": 1}]}
null
List IdeaLab ideas by creation date
List of IdeaLab ideas by the date they were created. Note: Ideas will only show up on this list if they are still categorized as Ideas. Last run on 9/17/2014
#list IdeaLab ideas by creation date SELECT page_title, rev_id, rev_timestamp, rev_comment, rev_user_text FROM metawiki_p.page p INNER JOIN metawiki_p.categorylinks cl ON p.page_id = cl.cl_from INNER JOIN metawiki_p.revision r ON p.page_id = r.rev_page WHERE p.page_namespace = 200 AND cl.cl_to IN ("IdeaLab/Ideas/IdeaLab") AND r.rev_parent_id = 0 ORDER BY rev_timestamp DESC;
{"resultsets": [{"headers": ["page_title", "rev_id", "rev_timestamp", "rev_comment", "rev_user_text"], "rowcount": 131}]}
null
list IdeaLab ideas created with Form Wizard
last run on 9/28/2014
#list IdeaLab ideas created with FormWizard by creation date SELECT page_title, rev_id, rev_timestamp, rev_comment, rev_user_text FROM metawiki_p.page p INNER JOIN metawiki_p.categorylinks cl ON p.page_id = cl.cl_from INNER JOIN metawiki_p.revision r ON p.page_id = r.rev_page WHERE p.page_namespace = 200 AND cl.cl_to IN ("IdeaLab/Ideas/IdeaLab") AND r.rev_parent_id = 0 and r.rev_comment like "Creating the idea%" ORDER BY rev_timestamp DESC;
{"resultsets": [{"headers": ["page_title", "rev_id", "rev_timestamp", "rev_comment", "rev_user_text"], "rowcount": 34}]}
null
list PEG proposals created with Form Wizard
last run 9/28/2014
#list IdeaLab ideas by creation date SELECT page_title, rev_id, rev_timestamp, rev_comment, rev_user_text FROM metawiki_p.page p INNER JOIN metawiki_p.categorylinks cl ON p.page_id = cl.cl_from INNER JOIN metawiki_p.revision r ON p.page_id = r.rev_page WHERE p.page_namespace = 200 AND rev_timestamp > 20140911000000 AND cl.cl_to IN ("Grants:PEG") AND r.rev_parent_id = 0 and r.rev_comment like "Creating the idea%" ORDER BY rev_timestamp DESC;
{"resultsets": [{"headers": ["page_title", "rev_id", "rev_timestamp", "rev_comment", "rev_user_text"], "rowcount": 3}]}
null
Wikidata item redirects
See https://www.wikidata.org/wiki/MediaWiki_talk:Gadget-Merge.js#wbcreateredirect https://www.wikidata.org/wiki/Wikidata:Project_chat#Deletion_vs_redirect for background.
USE wikidatawiki_p; SELECT page_title AS rd_from, rd_title AS rd_to, rev_timestamp AS timestamp, rev_user_text AS username FROM redirect JOIN page ON rd_from = page_id JOIN revision ON page_latest = rev_id WHERE page_namespace = 0 AND rd_interwiki = '' ORDER BY page_touched DESC;
{"resultsets": [{"headers": ["rd_from", "rd_to", "timestamp", "username"], "rowcount": 19928}]}
null
Too late images from WLM in France 2014
null
SELECT /* SLOW_OK */ page.page_title, image.img_timestamp, oldimage.oi_timestamp FROM image CROSS JOIN page ON image.img_name = page.page_title CROSS JOIN categorylinks ON page.page_id = categorylinks.cl_from LEFT JOIN oldimage ON image.img_name = oldimage.oi_name AND oldimage.oi_timestamp = (SELECT MIN(o.oi_timestamp) FROM oldimage o WHERE o.oi_name = image.img_name) WHERE categorylinks.cl_to = "Images_from_Wiki_Loves_Monuments_2014_in_France" AND IF(oldimage.oi_timestamp IS NULL, img_timestamp, oldimage.oi_timestamp) > 20140930220000 ORDER BY image.img_timestamp ASC;
{"resultsets": [{"headers": ["page_title", "img_timestamp", "oi_timestamp"], "rowcount": 0}]}
null
list IEG proposals created with Form Wizard
last run 10/1/2014
#list IEG proposals by creation date SELECT page_title, rev_id, rev_timestamp, rev_comment, rev_user_text FROM metawiki_p.page p INNER JOIN metawiki_p.categorylinks cl ON p.page_id = cl.cl_from INNER JOIN metawiki_p.revision r ON p.page_id = r.rev_page WHERE p.page_namespace = 200 AND rev_timestamp > 20140911000000 AND cl.cl_to IN ("IEG_2014_round_2") AND r.rev_parent_id = 0 and r.rev_comment like "Creating the idea%" ORDER BY rev_timestamp DESC;
{"resultsets": [{"headers": ["page_title", "rev_id", "rev_timestamp", "rev_comment", "rev_user_text"], "rowcount": 7}]}
null
Antal användare som upp ger att de är män eller kvinnor på svenska Wikipedia
Räknar alla som har angett att de vill bli tilltalade som män eller kvinnor på svenska Wikipedia. Observera att endast en liten andel (<3% 2014-10-03) har gjort den inställningen.
SELECT count(user_name) AS Män, (SELECT count(user_name) FROM svwiki_p.user JOIN svwiki_p.user_properties ON up_user = user_id WHERE up_property = 'gender' AND up_value = 'female') AS Kvinnor FROM svwiki_p.user JOIN svwiki_p.user_properties ON up_user = user_id WHERE up_property = 'gender' AND up_value = 'male'
{"resultsets": [{"headers": ["M\u00e4n", "Kvinnor"], "rowcount": 1}]}
null
User sandbox pages on pl.wp where the last edit was made with VisualEditor
null
-- User sandbox pages on pl.wp where the last edit was made with VisualEditor select concat("User:", page_title) as sandboxpage from plwiki_p.page left join plwiki_p.revision on page_latest = rev_id left join plwiki_p.change_tag on rev_id = ct_rev_id where page_title like "%/brudnopis%" and page_namespace = 2 and ct_tag = "visualeditor";
{"resultsets": [{"headers": ["sandboxpage"], "rowcount": 617}]}
null
Deleted/non-existing items in use on Wikidata
null
USE wikidatawiki_p; SELECT pl_title, count(*) FROM pagelinks WHERE pl_from_namespace=0 AND pl_namespace=0 AND NOT EXISTS(SELECT * FROM page WHERE pl_title = page_title AND pl_namespace = page_namespace) GROUP BY pl_title ORDER BY count(*) DESC;
{"resultsets": [{"headers": ["pl_title", "count(*)"], "rowcount": 219}]}
null
fiwiki abuse filter hits per day
fiwiki abuse filter hits per day
use fiwiki_p; SELECT str_to_date(floor(afl_timestamp/1000000), "%Y%m%d") as year_month_day, sum(1) as sum, floor(afl_timestamp/1000000) as ymd FROM abuse_filter_log GROUP BY year_month_day;
{"resultsets": [{"headers": ["year_month_day", "sum", "ymd"], "rowcount": 1991}]}
null
fiwiki abuse filter hits per day limited by filter_id
null
use fiwiki_p; SELECT str_to_date(floor(afl_timestamp/1000000), "%Y%m%d") as year_month_day, sum(1) as sum, floor(afl_timestamp/1000000) as ymd FROM abuse_filter_log WHERE afl_filter IN (26, 27, 28) GROUP BY year_month_day;
{"resultsets": [{"headers": ["year_month_day", "sum", "ymd"], "rowcount": 98}]}
null
fiwiki abuse filter hits per day limited by afl_actions
null
use fiwiki_p; SELECT str_to_date(floor(afl_timestamp/1000000), "%Y%m%d") as year_month_day, sum(1) as sum, floor(afl_timestamp/1000000) as ymd FROM abuse_filter_log WHERE afl_actions LIKE "%disallow%" GROUP BY year_month_day;
{"resultsets": [{"headers": ["year_month_day", "sum", "ymd"], "rowcount": 1958}]}
null
Thanks per day in Enwiki (see query/326)
Thanks per day in Enwiki (see query/326)
SELECT LEFT(log_timestamp, 8) as day, COUNT(*) FROM logging WHERE log_type="thanks" GROUP BY day;
{"resultsets": [{"headers": ["day", "COUNT(*)"], "rowcount": 495}]}
null
Thanks/month on enwiki (see query/216)
null
SELECT LEFT(log_timestamp, 6) as month, COUNT(*) FROM logging WHERE log_type="thanks" GROUP BY month;
{"resultsets": [{"headers": ["month", "COUNT(*)"], "rowcount": 18}]}
null
Thanks per day in dewiki
null
USE dewiki_p; SELECT substr(log_timestamp, 1, 8) AS date, COUNT(*) FROM logging WHERE log_type="thanks" GROUP BY date;
{"resultsets": [{"headers": ["date", "COUNT(*)"], "rowcount": 321}]}
null
Daily article deletions in dewiki
null
USE dewiki_p; SELECT DATE( log_timestamp ) AS DATE, COUNT( log_id ) AS deletions FROM logging WHERE log_action='delete' AND log_namespace =0 GROUP BY DATE( log_timestamp )
{"resultsets": [{"headers": ["DATE", "deletions"], "rowcount": 3575}]}
null
Active new editors in dewiki
(very new account on dewiki that has been created within the past week, has made at least 10 edits, is not a bot, and has not been blocked yet) see query/322
SELECT user_id, user_name, user_registration, user_editcount FROM dewiki_p.user WHERE user_registration > DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 7 DAY),'%Y%m%d%H%i%s') AND user_editcount > 10 AND user_id NOT IN (SELECT ug_user FROM dewiki_p.user_groups WHERE ug_group = 'bot') AND user_name NOT IN (SELECT REPLACE(log_title,"_"," ") FROM dewiki_p.logging WHERE log_type = "block" AND log_action = "block" AND log_timestamp > DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 8 DAY),'%Y%m%d%H%i%s'));
{"resultsets": [{"headers": ["user_id", "user_name", "user_registration", "user_editcount"], "rowcount": 42}]}
null
Daily file deletions in commonswiki
null
USE commonswiki_p; SELECT DATE( log_timestamp ) AS DATE, COUNT( log_id ) AS deletions FROM logging WHERE log_action='delete' AND log_namespace =0 GROUP BY DATE( log_timestamp )
{"resultsets": [{"headers": ["DATE", "deletions"], "rowcount": 3478}]}
null
All tables in the commonswiki_p database
All of the queriable tables in the public Commons.wikimedia database. See query/279
SHOW TABLES FROM commonswiki_p;
{"resultsets": [{"headers": ["Tables_in_commonswiki_p"], "rowcount": 65}]}
null
All tables in the dewiki_p database
All of the queriable tables in the public German Wikipedia database. See query/279 and query/653.
SHOW TABLES FROM dewiki_p;
{"resultsets": [{"headers": ["Tables_in_dewiki_p"], "rowcount": 84}]}
null
A list of merged and deleted Wikidata items (with false negatives and false positives)
null
USE wikidatawiki_p; SELECT log_title,log_comment FROM logging WHERE log_namespace = 0 AND log_type = "delete" AND (log_comment LIKE "%Merg%" OR log_comment LIKE "%merg%");
{"resultsets": [{"headers": ["log_title", "log_comment"], "rowcount": 449815}]}
null
Anexos a serem movidos (1ª etapa)
null
USE ptwiki_p; SELECT CONCAT('Anexo:', REPLACE(ax.page_title, '_', ' ')) Anexos FROM page a INNER JOIN page ax ON a.page_title = ax.page_title AND a.page_namespace = 0 AND ax.page_namespace = 102 INNER JOIN redirect ON rd_from = a.page_id AND rd_namespace = 102 AND rd_title = ax.page_title INNER JOIN revision ON a.page_id = rev_page WHERE a.page_is_redirect AND ax.page_is_redirect = 0 GROUP BY a.page_id HAVING COUNT(*) = 1;
{"resultsets": [{"headers": ["Anexos"], "rowcount": 4115}]}
null
Anexos a serem movidos (2ª etapa)
null
USE ptwiki_p; SELECT CONCAT('Anexo:', REPLACE(page_title, '_', ' ')) Anexos FROM page WHERE page_namespace = 102 AND NOT page_is_redirect AND page_title NOT IN (SELECT page_title FROM page WHERE page_namespace = 0 );
{"resultsets": [{"headers": ["Anexos"], "rowcount": 10757}]}
null
Anexos a serem movidos (3ª etapa)
null
USE ptwiki_p; SELECT CONCAT('Anexo:', REPLACE(ax.page_title, '_', ' ')) Anexos FROM page a INNER JOIN page ax ON a.page_title = ax.page_title AND a.page_namespace = 0 AND ax.page_namespace = 102 INNER JOIN redirect ON rd_from = a.page_id AND rd_namespace = 102 AND rd_title = ax.page_title INNER JOIN revision ON a.page_id = rev_page WHERE a.page_is_redirect AND ax.page_is_redirect = 0 GROUP BY a.page_id HAVING COUNT(*) > 1;
{"resultsets": [{"headers": ["Anexos"], "rowcount": 305}]}
null
Artigos e anexos de mesmo nome
null
USE ptwiki_p; SELECT REPLACE(ax.page_title, '_', ' ') AS `Artigo/Anexo` FROM page a INNER JOIN page ax ON a.page_title = ax.page_title AND a.page_namespace = 0 AND ax.page_namespace = 102 WHERE NOT a.page_is_redirect AND NOT ax.page_is_redirect;
{"resultsets": [{"headers": ["Artigo/Anexo"], "rowcount": 8}]}
null
Anexos com "...por ordem..."
null
USE ptwiki_p; SELECT CONCAT('Anexo:', REPLACE(page_title, '_', ' ')) Anexos FROM page WHERE page_namespace = 102 AND page_title LIKE '%por\_ordem\_%';
{"resultsets": [{"headers": ["Anexos"], "rowcount": 13}]}
null
IdeaLab ideas created per month
Ideas created per month. Note: Ideas will only show up on this list if they are still categorized as Ideas. Last run on 9/17/2014
#count IdeaLab ideas created per month SELECT EXTRACT(YEAR FROM DATE_FORMAT(rev_timestamp,'%Y%m%d%H%i%s')) AS `year`, EXTRACT(MONTH FROM DATE_FORMAT(rev_timestamp,'%Y%m%d%H%i%s')) AS `month`, COUNT(rev_id) AS ideas_created FROM metawiki_p.revision r INNER JOIN metawiki_p.page AS p ON r.rev_page = p.page_id INNER JOIN metawiki_p.categorylinks AS cl ON p.page_id = cl.cl_from WHERE p.page_namespace = 200 AND cl.cl_to IN ("IdeaLab/Ideas/IdeaLab") AND r.rev_parent_id = 0 GROUP BY `year`, `month` ORDER BY `year` ASC, `month` ASC;
{"resultsets": [{"headers": ["year", "month", "ideas_created"], "rowcount": 21}]}
null
Utilizadores recentes mais activos
Active new editors - pt.wikipedia
SELECT user_id, user_name, user_registration, user_editcount FROM ptwiki_p.user WHERE user_registration > DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 7 DAY),'%Y%m%d%H%i%s') AND user_editcount > 10 AND user_id NOT IN (SELECT ug_user FROM ptwiki_p.user_groups WHERE ug_group = 'bot') AND user_name NOT IN (SELECT REPLACE(log_title,"_"," ") FROM ptwiki_p.logging WHERE log_type = "block" AND log_action = "block" AND log_timestamp > DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 8 DAY),'%Y%m%d%H%i%s'));
{"resultsets": [{"headers": ["user_id", "user_name", "user_registration", "user_editcount"], "rowcount": 34}]}
null
Eliminações por dia
deleted articles / day
USE ptwiki_p; SELECT DATE( log_timestamp ) AS DATE, COUNT( log_id ) AS deletions FROM logging WHERE log_action='delete' AND log_namespace =0 GROUP BY DATE( log_timestamp )
{"resultsets": [{"headers": ["DATE", "deletions"], "rowcount": 3558}]}
null
Utilizadores que mais agradecem
utilizadores que mais agradecem
USE ptwiki_p; SELECT log_user_text, COUNT(*) FROM logging WHERE log_type="thanks" GROUP BY log_user_text ORDER BY COUNT(*) DESC LIMIT 100;
{"resultsets": [{"headers": ["log_user_text", "COUNT(*)"], "rowcount": 100}]}
null
Masc vs Femin in dewiki
see query/669
SELECT count(user_name) AS Masc, (SELECT count(user_name) FROM dewiki_p.user JOIN dewiki_p.user_properties ON up_user = user_id WHERE up_property = 'gender' AND up_value = 'female') AS Femin FROM dewiki_p.user JOIN dewiki_p.user_properties ON up_user = user_id WHERE up_property = 'gender' AND up_value = 'male'
{"resultsets": [{"headers": ["Masc", "Femin"], "rowcount": 1}]}
null
deleted Wikidata items, again
copy of Whym's query of deleted Wikidata items
USE wikidatawiki_p; SELECT pl_title, count(*) FROM pagelinks WHERE pl_from_namespace=0 AND pl_namespace=0 AND NOT EXISTS(SELECT * FROM page WHERE pl_title = page_title AND pl_namespace = page_namespace) GROUP BY pl_title ORDER BY count(*) DESC;
{"resultsets": [{"headers": ["pl_title", "count(*)"], "rowcount": 23}]}
null
Disallowed - abuse filter
null
USE ptwiki_p; SELECT SUBSTR(afl_timestamp, 1, 6) AS MONTH, COUNT(afl_id) AS edits FROM abuse_filter_log WHERE afl_action = 'edit' AND afl_actions LIKE '%disallow%' GROUP BY MONTH;
{"resultsets": [{"headers": ["MONTH", "edits"], "rowcount": 65}]}
null
Warn - abuse filter
null
USE ptwiki_p; SELECT SUBSTR(afl_timestamp, 1, 6) AS MONTH, COUNT(afl_id) AS edits FROM abuse_filter_log WHERE afl_action = 'edit' AND afl_actions LIKE '%warn%' GROUP BY MONTH;
{"resultsets": [{"headers": ["MONTH", "edits"], "rowcount": 67}]}
null
flag - abuse filter
null
USE ptwiki_p; SELECT SUBSTR(afl_timestamp, 1, 6) AS MONTH, COUNT(afl_id) AS edits FROM abuse_filter_log WHERE afl_action = 'edit' AND afl_actions LIKE '%flag%' GROUP BY MONTH;
{"resultsets": [{"headers": ["MONTH", "edits"], "rowcount": 0}]}
null
Anexos em que o artigo de mesmo título não redireciona para ele
null
USE ptwiki_p; SELECT CONCAT('Anexo:', REPLACE(ax.page_title, '_', ' ')) Anexos FROM page a INNER JOIN page ax ON a.page_title = ax.page_title AND a.page_namespace = 0 AND ax.page_namespace = 102 INNER JOIN redirect ON rd_from = a.page_id WHERE NOT ax.page_is_redirect AND (rd_namespace != 102 OR rd_title != ax.page_title);
{"resultsets": [{"headers": ["Anexos"], "rowcount": 25}]}
null
Fiwiki revert analysis
null
use fiwiki_p; select concat("; [[", replace(page_title, "_", " ") ,"]]"), concat("<small>[https://fi.wikipedia.org/w/index.php?diff=prev&oldid=", rev_id, " ", rev_id, "]</small>:") as link, rev_user_text, ": <i>" as delim, rev_comment, "</i>" as end from page, revision where rev_timestamp > 20141000000000 and rev_timestamp < 20141008000000 and rev_page=page_id and page_namespace=0 and rev_comment regexp "revert|[Kk]umot|[Hh]ylät|[Pp]alaut|rv[, ]" ;
{"resultsets": [{"headers": ["concat(\"; [[\", replace(page_title, \"_\", \" \") ,\"]]\")", "link", "rev_user_text", "delim", "rev_comment", "end"], "rowcount": 548}]}
null
Derping up some edit counts
null
SELECT COUNT(*) FROM revision_userindex INNER JOIN page ON rev_page = page_id WHERE rev_user_text = "Inferior Olive" AND page_namespace = 0; SELECT COUNT(*) FROM revision_userindex INNER JOIN page ON rev_page = page_id WHERE rev_user_text = "Jimbo Wales" AND page_namespace = 0; SELECT COUNT(*) FROM revision_userindex INNER JOIN page ON rev_page = page_id WHERE rev_user_text = "Koavf" AND page_namespace = 0; SELECT COUNT(*) FROM revision_userindex INNER JOIN page ON rev_page = page_id WHERE rev_user_text = "Ironholds" AND page_namespace = 0;
{"resultsets": [{"headers": ["COUNT(*)"], "rowcount": 1}, {"headers": ["COUNT(*)"], "rowcount": 1}, {"headers": ["COUNT(*)"], "rowcount": 1}, {"headers": ["COUNT(*)"], "rowcount": 1}]}
null
Get a few deleted pages from archive
null
SELECT DISTINCT ar_namespace, ar_title FROM (SELECT ar_namespace, ar_title FROM archive LIMIT 100000) AS sampled_archive;
{"resultsets": [{"headers": ["ar_namespace", "ar_title"], "rowcount": 26967}]}
null
Best deleters on Wikidata
TODO: use percent of still non-existing pages out of total deletions
USE wikidatawiki_p; SELECT log_user_text, COUNT(*) FROM logging WHERE log_type="delete" AND log_action="delete" AND log_namespace=0 GROUP BY log_user_text ORDER BY COUNT(*) DESC LIMIT 1000;
{"resultsets": [{"headers": ["log_user_text", "COUNT(*)"], "rowcount": 166}]}
null
Portal icons on itwiki
null
USE itwiki_p; SELECT log_title, log_action, log_user_text FROM logging WHERE log_namespace=100 AND log_type='delete' AND log_title LIKE '%icona%';
{"resultsets": [{"headers": ["log_title", "log_action", "log_user_text"], "rowcount": 571}]}
null
Top 25 most edited articles on dewiki
Top 25 most edited articles on dewiki in the last month
USE dewiki_p; SELECT rc_title, COUNT(*) AS num_edits FROM recentchanges WHERE rc_namespace = 0 GROUP BY rc_title ORDER BY num_edits DESC LIMIT 25;
{"resultsets": [{"headers": ["rc_title", "num_edits"], "rowcount": 25}]}
null
WMF accounts recently active on MetaWiki
last run on October 19, 2014
select distinct u.user_name, "metawiki" from metawiki_p.user u join metawiki_p.recentchanges rc on u.user_id = rc.rc_user where u.user_name like "%(WMF)";
{"resultsets": [{"headers": ["user_name", "metawiki"], "rowcount": 77}]}
null
# of users who registered in the previous year
null
SELECT COUNT(*) FROM user WHERE user_registration BETWEEN DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 YEAR), "%Y%m%d%H%i%S") AND DATE_FORMAT(NOW(), "%Y%m%d%H%i%S");
{"resultsets": [{"headers": ["COUNT(*)"], "rowcount": 1}]}
null
# of revisions saved in the last year
null
SELECT COUNT(*) FROM revision WHERE rev_timestamp BETWEEN DATE_FORMAT(DATE_SUB(NOW(), INTERVAL 1 YEAR), "%Y%m%d%H%i%S") AND DATE_FORMAT(NOW(), "%Y%m%d%H%i%S");
{"resultsets": [{"headers": ["COUNT(*)"], "rowcount": 1}]}
null
Daily number of "thanks" on ptwiki
null
USE ptwiki_p; SELECT LEFT(log_timestamp, 8) as day, COUNT(*) FROM logging WHERE log_type="thanks" GROUP BY day;
{"resultsets": [{"headers": ["day", "COUNT(*)"], "rowcount": 429}]}
null
Edit Success & Deletes with User Account Age
null
select revision.rev_user, user.user_editcount, user.user_registration as registration_time, revision.rev_len, revision.rev_minor_edit, revision.rev_timestamp from revision, user where revision.rev_user >= "22900000" and revision.rev_user < "22908538" and user.user_id = revision.rev_user ;
{"resultsets": [{"headers": ["rev_user", "user_editcount", "registration_time", "rev_len", "rev_minor_edit", "rev_timestamp"], "rowcount": 5003}]}
null
<script>alert("XSS");</script>
<script>alert("XSS");</script>
SELECT "<script>alert('XSS');</script>" FROM nlwiki_p.user LIMIT 1;
{"resultsets": [{"headers": ["<script>alert('XSS');</script>"], "rowcount": 1}]}
null
MediaWiki extensions without Extension template
null
USE mediawikiwiki_p; SELECT page_title FROM page WHERE page_namespace = 102 AND page_is_redirect = 0 AND page_title NOT LIKE '%/%' AND page_id NOT IN (SELECT tl_from FROM templatelinks WHERE tl_namespace = 10 AND tl_title = 'Extension') AND page_id NOT IN (SELECT cl_from FROM categorylinks WHERE cl_to = 'Archived_extensions' OR cl_to = 'Deleted_extensions_with_security_vulnerabilities') ORDER BY page_title;
{"resultsets": [{"headers": ["page_title"], "rowcount": 60}]}
null
MediaWiki extensions without 'install' templates
null
USE mediawikiwiki_p; SELECT page_title FROM page WHERE page_namespace = 102 AND page_is_redirect = 0 AND page_title NOT LIKE '%/%' AND page_id NOT IN ( SELECT tl_from FROM templatelinks WHERE tl_namespace = 10 AND ( tl_title LIKE 'ExtensionInstall%' OR tl_title LIKE 'ExtensionGitDownload%' ) ) AND page_id NOT IN ( SELECT cl_from FROM categorylinks WHERE cl_to = 'Archived_extensions' OR cl_to = 'Deleted_extensions_with_security_vulnerabilities' OR cl_to = 'Extensions_which_host_their_code_in-wiki' ) ORDER BY page_title;
{"resultsets": [{"headers": ["page_title"], "rowcount": 1382}]}
null
Commons files with no machine-readable authors that are used more than 20 times
null
USE commonswiki_p; SELECT page_title, COUNT(*) as links FROM categorylinks INNER JOIN page ON cl_from = page_id INNER JOIN globalimagelinks ON page_title = gil_to WHERE cl_to="Files_with_no_machine-readable_author" GROUP BY gil_to HAVING links > 20 ORDER BY links DESC;
{"resultsets": [{"headers": ["page_title", "links"], "rowcount": 43258}]}
null
Predefinições não utilizadas
null
USE ptwiki_p; SELECT CONCAT('Predefinição:', Replace(page_title, '_', ' ')) Predefinição, MAX(rev_timestamp) Última, rev_user_text Criador, Redir FROM (SELECT page_id, page_title, IF(page_is_redirect, 'Sim', '') Redir FROM page WHERE page_namespace = 10 AND page_title NOT IN (SELECT DISTINCT tl_title FROM templatelinks WHERE tl_namespace = 10) ) pages INNER JOIN revision ON page_id = rev_page GROUP BY page_id;
{"resultsets": [{"headers": ["Predefini\u00e7\u00e3o", "\u00daltima", "Criador", "Redir"], "rowcount": 6801}]}
null
(en.wp) Wikipedia:Database reports/Unused non-free files
SQL from https://en.wikipedia.org/wiki/Wikipedia:Database_reports/Unused_non-free_files/Configuration
SELECT page_namespace, page_title FROM page JOIN categorylinks AS cl1 ON cl1.cl_from = page_id LEFT JOIN imagelinks ON il_to = page_title AND page_namespace = 6 LEFT JOIN categorylinks AS cl2 ON cl2.cl_from = page_id AND cl2.cl_to = 'All_orphaned_non-free_use_Wikipedia_files' LEFT JOIN redirect ON rd_title = page_title AND rd_namespace = 6 WHERE cl1.cl_to = 'All_non-free_media' AND il_from IS NULL AND cl2.cl_from IS NULL AND rd_from IS NULL AND page_is_redirect = 0;
{"resultsets": [{"headers": ["page_namespace", "page_title"], "rowcount": 1453}]}
null
Top editors who registered in the last month
Exclude bots and users who have been blocked. I think this is correct, I am not an expert on these tables.
SELECT user_name, user_editcount FROM enwiki_p.user WHERE user_registration > DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 30 DAY),'%Y%m%d%H%i%s') AND user_id NOT IN (SELECT ug_user FROM enwiki_p.user_groups WHERE ug_group = 'bot') AND user_name not in (SELECT REPLACE(log_title,"_"," ") from enwiki_p.logging where log_type = "block" and log_action = "block" and log_timestamp > DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 31 DAY),'%Y%m%d%H%i%s')) ORDER BY user_editcount DESC LIMIT 100;
{"resultsets": [{"headers": ["user_name", "user_editcount"], "rowcount": 100}]}
null
Test query
trying to get top enwiki editors of all time but not accurate. I'm not filtering for blocked correctly.
SELECT user_name, user_editcount FROM enwiki_p.user WHERE user_id NOT IN (SELECT ug_user FROM enwiki_p.user_groups WHERE ug_group = 'bot') AND user_name not in (SELECT REPLACE(log_title,"_"," ") from enwiki_p.logging where log_type = "block" and log_action = "block" and log_timestamp > DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 31 DAY),'%Y%m%d%H%i%s')) ORDER BY user_editcount DESC LIMIT 100;
{"resultsets": [{"headers": ["user_name", "user_editcount"], "rowcount": 100}]}
null
Tables enwiki
null
SHOW TABLES FROM enwiki_p;
{"resultsets": [{"headers": ["Tables_in_enwiki_p"], "rowcount": 108}]}
null
Long tennis articles
Articles containing the word 'tennis' in the title which are over 100000 characters long
SELECT page_title, page_len FROM page WHERE page_namespace=0 AND page_title LIKE '%tennis%' AND page_len > 100000 LIMIT 100;
{"resultsets": [{"headers": ["page_title", "page_len"], "rowcount": 16}]}
null
Commons files with no machine-readable author that are used more than 20 times
null
USE commonswiki_p; SELECT page_title, COUNT(*) AS links FROM categorylinks INNER JOIN page ON cl_from = page_id INNER JOIN globalimagelinks ON page_title = gil_to WHERE cl_to="Files_with_no_machine-readable_author" GROUP BY gil_to HAVING links > 20 ORDER BY links DESC;
{"resultsets": [{"headers": ["page_title", "links"], "rowcount": 45312}]}
null
Últimas edições dos robôs
null
USE ptwiki_p; SELECT rev_user_text Robô, MAX(rev_timestamp) Última_edição FROM revision_userindex WHERE rev_user IN (SELECT ug_user FROM user_groups WHERE ug_group = 'bot') GROUP BY rev_user;
{"resultsets": [{"headers": ["Rob\u00f4", "\u00daltima_edi\u00e7\u00e3o"], "rowcount": 210}]}
null
Wikisource DNB pages
null
use enwikisource_p; SELECT iwlinks.iwl_title, page.page_title FROM iwlinks INNER JOIN page ON page.page_id = iwlinks.iwl_from WHERE page.page_title LIKE '%(DNB00)' AND page.page_namespace=0 AND iwlinks.iwl_prefix='w';
{"resultsets": [{"headers": ["iwl_title", "page_title"], "rowcount": 22420}]}
null
2014-15 APG proposals edits
null
SELECT `rev_user_text`, page_title, rev_timestamp FROM metawiki_p.revision JOIN metawiki_p.page ON `page_id` = `rev_page` WHERE `page_title` LIKE 'APG/Proposals/2014-2015_round1/%/Proposal_form' AND `page_namespace` = 201 AND rev_timestamp > '20141001000000' AND rev_timestamp < '20141101000000' ORDER BY rev_timestamp; SELECT page_title, COUNT(*) FROM metawiki_p.revision JOIN metawiki_p.page ON `page_id` = `rev_page` WHERE `page_title` LIKE 'APG/Proposals/2014-2015_round1/%/Proposal_form' AND `page_namespace` = 201 AND rev_timestamp > '20141001000000' AND rev_timestamp < '20141101000000' GROUP BY page_title ORDER BY COUNT(*); SELECT rev_user_text, COUNT(*) FROM metawiki_p.revision JOIN metawiki_p.page ON `page_id` = `rev_page` WHERE `page_title` LIKE 'APG/Proposals/2014-2015_round1/%/Proposal_form' AND `page_namespace` = 201 AND rev_timestamp > '20141001000000' AND rev_timestamp < '20141101000000' GROUP BY rev_user_text ORDER BY COUNT(*);
{"resultsets": [{"headers": ["rev_user_text", "page_title", "rev_timestamp"], "rowcount": 373}, {"headers": ["page_title", "COUNT(*)"], "rowcount": 11}, {"headers": ["rev_user_text", "COUNT(*)"], "rowcount": 77}]}
null
2013-14 APG proposals edits
null
SELECT `rev_user_text`, page_title, rev_timestamp FROM metawiki_p.revision JOIN metawiki_p.page ON `page_id` = `rev_page` WHERE `page_title` LIKE 'APG/Proposals/2013-2014_round1/%/Proposal_form' AND `page_namespace` = 201 AND rev_timestamp > '20131001000000' AND rev_timestamp < '20131101000000' ORDER BY rev_timestamp; SELECT page_title, COUNT(*) FROM metawiki_p.revision JOIN metawiki_p.page ON `page_id` = `rev_page` WHERE `page_title` LIKE 'APG/Proposals/2013-2014_round1/%/Proposal_form' AND `page_namespace` = 201 AND rev_timestamp > '20131001000000' AND rev_timestamp < '20131101000000' GROUP BY page_title ORDER BY COUNT(*); SELECT rev_user_text, COUNT(*) FROM metawiki_p.revision JOIN metawiki_p.page ON `page_id` = `rev_page` WHERE `page_title` LIKE 'APG/Proposals/2013-2014_round1/%/Proposal_form' AND `page_namespace` = 201 AND rev_timestamp > '20131001000000' AND rev_timestamp < '20131101000000' GROUP BY rev_user_text ORDER BY COUNT(*);
{"resultsets": [{"headers": ["rev_user_text", "page_title", "rev_timestamp"], "rowcount": 562}, {"headers": ["page_title", "COUNT(*)"], "rowcount": 13}, {"headers": ["rev_user_text", "COUNT(*)"], "rowcount": 113}]}
null
Wikidata items with sitelinks to Institution pages on Commons (count)
Count of Wikidata items with sitelinks to pages in the Institution: namespace on Commons. Published at https://www.wikidata.org/wiki/Wikidata:WikiProject_Structured_Data_for_Commons/Phase_1_progress/Links/Institution
use wikidatawiki_p; SELECT COUNT(*) FROM wb_items_per_site WHERE ips_site_id='commonswiki' AND ips_site_page LIKE 'Institution:%';
{"resultsets": [{"headers": ["COUNT(*)"], "rowcount": 1}]}
null
Wikidata items with sitelinks to Institution templates on Commons (formatted)
A formatted list of Wikidata items with sitelinks to pages in the Insitution: namespace on Commons. Published at https://www.wikidata.org/wiki/Wikidata:WikiProject_Structured_Data_for_Commons/Phase_1_progress/Links/Institution For an unformatted list, use http://quarry.wmflabs.org/query/487
use wikidatawiki_p; SELECT CONCAT('* [[Q', ips_item_id, ']] : [[:c:', ips_site_page, ']] <--- {{Q|', ips_item_id, '}}') AS '== List of sitelinks ==' FROM wb_items_per_site WHERE ips_site_id='commonswiki' AND ips_site_page LIKE 'Institution:%' ORDER BY ips_item_id;
{"resultsets": [{"headers": ["== List of sitelinks =="], "rowcount": 4}]}
null
Wikidata items with sitelinks to File pages on Commons (formatted)
A formatted list of Wikidata items with sitelinks to File pages on Commons. Published at https://www.wikidata.org/wiki/Wikidata:WikiProject_Structured_Data_for_Commons/Phase_1_progress/Links/File For an unformatted list, use http://quarry.wmflabs.org/query/450
use wikidatawiki_p; SELECT CONCAT('* [[Q', ips_item_id, ']] : [[:c:', ips_site_page, ']] <--- {{Q|', ips_item_id, '}}') AS '== List of sitelinks ==' FROM wb_items_per_site WHERE ips_site_id='commonswiki' AND ips_site_page LIKE 'File:%' ORDER BY ips_item_id;
{"resultsets": [{"headers": ["== List of sitelinks =="], "rowcount": 8}]}
null
Get Commons file uploaders in category
List creators and creation date for Wikimedia commons files in a given category. Last run November 13, 2014
#1 SELECT rev_user_text, rev_user, rev_id, rev_timestamp, page_title, cl_to #2 FROM commonswiki_p.page p #3 INNER JOIN commonswiki_p.categorylinks cl ON p.page_id = cl.cl_from #4 INNER JOIN commonswiki_p.revision r ON p.page_id = r.rev_page #5 WHERE p.page_namespace = 6 #6 AND cl.cl_to IN ("Views_of_Seattle_from_Elliott_Bay") #7 AND r.rev_parent_id = 0; #LINE 1: declare which database fields (columns) you want to include in your output. #You can include any fields from any of the tables you are joining (in this case: page, categorylinks, revision) #LINE 2: declare which wiki you are pulling data from. #In this case, commonswiki_p. You can find a full list here: https://tools.wmflabs.org/tools-info/?dblist=s1.labsdb #LINE 3: join the page table with the categorylinks table on their COMMON KEY, which is the id of the page. #LINE 4: join the page table with the revision table on their COMMON KEY, which is the id of the page. #LINE 5: specify the numeric namespace(s) of the pages you want to get information for. #There is a list of standard namespaces here: https://en.wikipedia.org/wiki/Wikipedia:Namespace #LINE 6: specify the category(ies) that the pages are in. If you wanted to get pages from multipe categories, #you would write the query the same way: AND cl.cl_to IN ("My_first_category", "Another_category") #LINE 7: specify that you want to return the revision information from the FIRST revision to the page. #the "parent" of a revision is the previous revision to that page. #The first revision to a page doesn't have a "parent", so the value for rev_parent_id will be 0.
{"resultsets": [{"headers": ["rev_user_text", "rev_user", "rev_id", "rev_timestamp", "page_title", "cl_to"], "rowcount": 39}]}
null
fa.title query
null
USE fawiki_p; SELECT page_title FROM page WHERE page_namespace = 0 AND page_is_redirect = 0 AND page_title LIKE "%گورستان%";
{"resultsets": [{"headers": ["page_title"], "rowcount": 1290}]}
null
Articles about human by occupation on fawiki
Only articles that has '([occupation])' at the end of its name.
USE fawiki_p; SELECT `page_title` FROM `page` WHERE `page_is_redirect` = 0 AND `page_namespace` = 0 AND ( `page_title` LIKE '%(نوازنده%)' OR `page_title` LIKE '%(نویسنده%)' OR `page_title` LIKE '%(ورزشکار%)' OR `page_title` LIKE '%(رقصنده%)' OR `page_title` LIKE '%(فیزیک‌دان%)' OR `page_title` LIKE '%(ریاضی‌دان%)' OR `page_title` LIKE '%(دانشمند%)' OR `page_title` LIKE '%(اندیشمند%)' OR `page_title` LIKE '%(شیمی‌دان%)' OR `page_title` LIKE '%(فروشنده%)' OR `page_title` LIKE '%(راننده%)' OR `page_title` LIKE '%(بازیکن%)' OR `page_title` LIKE '%(ورزشکار%)' OR `page_title` LIKE '%(گوینده%)' OR `page_title` LIKE '%(موسیقی‌دان%)' OR `page_title` LIKE '%(سیاست‌مدار%)' OR `page_title` LIKE '%(رئیس‌جمهور%)' OR `page_title` LIKE '%(تهیه‌کننده%)' OR `page_title` LIKE '%(هنرمند%)' OR `page_title` LIKE '%(هنرپیشه%)' OR `page_title` LIKE '%(نماینده%)' OR `page_title` LIKE '%(ولی فقیه%)' OR `page_title` LIKE '%(روحانی%)' OR `page_title` LIKE '%(هنرپیشه%)' OR `page_title` LIKE '%(آموزگار%)' OR `page_title` LIKE '%(منطق‌دان%)' OR `page_title` LIKE '%(کارآفرین%)' OR `page_title` LIKE '%(حقوق‌دان%)' OR `page_title` LIKE '%(قاضی%)' OR `page_title` LIKE '%(حامی%)' OR `page_title` LIKE '%(موبد%)' OR `page_title` LIKE '%(شورشی%)' OR `page_title` LIKE '%(پژوهشگر%)' OR `page_title` LIKE '%(وکیل%)' OR `page_title` LIKE '%(گزارشگر%)' OR `page_title` LIKE '%(سرآشپز%)' OR `page_title` LIKE '%(اقتصاددان%)' OR (`page_title` LIKE '%(کارگردان%)' AND `page_title` NOT LIKE '%(کارگردانی%)') OR (`page_title` LIKE '%(نقاش%)' AND `page_title` NOT LIKE '%(نقاشی%)') OR (`page_title` LIKE '%(بازیگر%)' AND `page_title` NOT LIKE '%(بازیگری%)') OR (`page_title` LIKE '%(صدابردار%)' AND `page_title` NOT LIKE '%(صدابرداری%)') OR (`page_title` LIKE '%(فیلم‌بردار%)' AND `page_title` NOT LIKE '%(فیلم‌برداری%)') OR (`page_title` LIKE '%(شاعر%)' AND `page_title` NOT LIKE '%(شاعری%)') OR (`page_title` LIKE '%(مشاور%)' AND `page_title` NOT LIKE '%(مشاوری%)') OR (`page_title` LIKE '%(تاجر%)' AND `page_title` NOT LIKE '%(تاجری%)') OR (`page_title` LIKE '%(مهندس%)' AND `page_title` NOT LIKE '%(مهندسی%)') OR (`page_title` LIKE '%(رقاص%)' AND `page_title` NOT LIKE '%(رقاصی%)') OR (`page_title` LIKE '%(استاد%)' AND `page_title` NOT LIKE '%(استادی%)' AND `page_title` NOT LIKE '%(استادان%)') OR (`page_title` LIKE '%(استادیار%)' AND `page_title` NOT LIKE '%(استادیاری%)') OR (`page_title` LIKE '%(فوتبالیست%)' AND `page_title` NOT LIKE '%(فوتبالیست‌ها%)') OR (`page_title` LIKE '%(طراح%)' AND `page_title` NOT LIKE '%(طراحی%)') OR (`page_title` LIKE '%(خبرنگار%)' AND `page_title` NOT LIKE '%(خبرنگاری%)') OR (`page_title` LIKE '%(خلبان%)' AND `page_title` NOT LIKE '%(خلبانی%)') OR (`page_title` LIKE '%(معلم%)' AND `page_title` NOT LIKE '%(معلمی%)') OR (`page_title` LIKE '%(روزنامه‌نگار%)' AND `page_title` NOT LIKE '%(روزنامه‌نگاری%)') OR (`page_title` LIKE '%(مترجم%)' AND `page_title` NOT LIKE '%(مترجمی%)') #OR (`page_title` LIKE '%(سرباز%)' AND `page_title` NOT LIKE '%(سربازی%)') OR (`page_title` LIKE '%(عکاس%)' AND `page_title` NOT LIKE '%(عکاسی%)') OR (`page_title` LIKE '%(کارگردان%)' AND `page_title` NOT LIKE '%(کارگردانی%)') OR (`page_title` LIKE '%(شهردار%)' AND `page_title` NOT LIKE '%(شهرداری%)') OR (`page_title` LIKE '%(کارگر%)' AND `page_title` NOT LIKE '%(کارگری%)') OR (`page_title` LIKE '%(جهانگرد%)' AND `page_title` NOT LIKE '%(جهانگردی%)') OR (`page_title` LIKE '%(هوانورد%)' AND `page_title` NOT LIKE '%(هوانوردی%)') OR (`page_title` LIKE '%(بازاریاب%)' AND `page_title` NOT LIKE '%(بازاریابی%)') OR (`page_title` LIKE '%(دامپزشک%)' AND `page_title` NOT LIKE '%(دامپزشکی%)') OR (`page_title` LIKE '%(خواننده%)' AND `page_title` NOT LIKE 'ترانه‌شناسی%' AND `page_title` NOT LIKE 'همخوان%') OR (`page_title` LIKE '%(%شناس%)' AND `page_title` NOT LIKE '%(%شناسی%)') OR (`page_title` LIKE '%(%حسابدار%)' AND `page_title` NOT LIKE '%(%حسابداری%)') OR (`page_title` LIKE '%(%معمار%)' AND `page_title` NOT LIKE '%(%معماری%)') OR (`page_title` LIKE '%(%پزشک%)' AND `page_title` NOT LIKE '%(%پزشکی%)') OR (`page_title` LIKE '%(%پرستار%)' AND `page_title` NOT LIKE '%(%پرستاری%)') OR (`page_title` LIKE '%(%تحلیل‌گر%)' AND `page_title` NOT LIKE '%(%تحلیل‌گری%)') OR (`page_title` LIKE '%(%جراح%)' AND `page_title` NOT LIKE '%(%جراحی%)') OR (`page_title` LIKE '%(%کشاورز%)' AND `page_title` NOT LIKE '%(%کشاورزی%)') OR (`page_title` LIKE '%(%آشپز%)' AND `page_title` NOT LIKE '%(%آشپزی%)') OR (`page_title` LIKE '%(%کارگزار%)' AND `page_title` NOT LIKE '%(%کارگزاری%)') OR (`page_title` LIKE '%(%فروش%)' AND `page_title` NOT LIKE '%(%فروشی%)' AND `page_title` NOT LIKE '%(%فروشگاه%)') OR (`page_title` LIKE '%(%مأمور%)' AND `page_title` NOT LIKE '%(%مأموریت%)' AND `page_title` NOT LIKE '%(%مأموران%)') OR (`page_title` LIKE '%(%امدادگر%)' AND `page_title` NOT LIKE '%(%امدادگری%)' AND `page_title` NOT LIKE '%(%امدادگران%)') OR (`page_title` LIKE '%(%دلال%)' AND `page_title` NOT LIKE '%(%دلالی%)') OR (`page_title` LIKE '%(%مددکار%)' AND `page_title` NOT LIKE '%(%مددکاری%)' AND `page_title` NOT LIKE '%(%مددکاران%)') ##Following lines commented because of complete 'ساز' line after these lines. ##If You find out something wrong with the complete line and cannot do anything, ##please comment it and uncomment following lines. #OR (`page_title` LIKE '%(%داروساز%)' AND `page_title` NOT LIKE '%(%داروسازی%)') #OR (`page_title` LIKE '%(فیلم‌ساز%)' AND `page_title` NOT LIKE '%(فیلم‌سازی%)') #OR (`page_title` LIKE '%(بدنساز%)' AND `page_title` NOT LIKE '%(بدنسازی%)') #OR (`page_title` LIKE '%(آهنگ‌ساز%)' AND `page_title` NOT LIKE '%(آهنگ‌سازی%)') OR (`page_title` LIKE '%(%ساز%)' AND `page_title` NOT LIKE '%(%\_ساز%)' AND `page_title` NOT LIKE '%(%شبیه‌ساز%)' AND `page_title` NOT LIKE '%(%سازی%)' AND `page_title` NOT LIKE '%(ساز)' AND `page_title` NOT LIKE '%(%سازمان%)' AND `page_title` NOT LIKE '%(%سازه%)' AND `page_title` NOT LIKE '%(%سازوکار%)') #... ) GROUP BY `page_title` ORDER BY `page_title` ASC;
{"resultsets": [{"headers": ["page_title"], "rowcount": 1890}]}
null
Get a few, old anonymous mobile edits
null
USE itwiki_p; SELECT rev_id, rev_user, rev_user_text FROM revision_userindex INNER JOIN change_tag ON ct_rev_id = rev_id AND ct_tag = "mobile edit" WHERE rev_timestamp BETWEEN "20141025" AND "20141026" AND rev_user = 0 LIMIT 10;
{"resultsets": [{"headers": ["rev_id", "rev_user", "rev_user_text"], "rowcount": 10}]}
null
Get daily anonymous mobile edits from Italian Wikipedia
null
USE itwiki_p; SELECT LEFT(rev_timestamp, 8) AS date, COUNT(*) FROM revision_userindex INNER JOIN tag_summary ON ts_rev_id = rev_id AND ts_tags LIKE "%mobile edit%" AND ts_tags NOT LIKE "%mobile app edit%" WHERE rev_timestamp BETWEEN "20141028" AND "20141114" AND rev_user = 0 GROUP BY date;
{"resultsets": [{"headers": ["date", "COUNT(*)"], "rowcount": 13}]}
null
Newly registered users per day on Italian Wikipedia
null
USE itwiki_p; SELECT LEFT(log_timestamp, 8) AS date, COUNT(*) AS registrations FROM logging_userindex WHERE log_type = "newusers" AND log_action = "create" AND log_timestamp BETWEEN "20141025" AND "20141107" GROUP BY date;
{"resultsets": [{"headers": ["date", "registrations"], "rowcount": 13}]}
null
Enwiki table descriptions (revision, page, user, categorylinks)
Descriptions of the fields within 4 major tables on English Wikipedia: revision (edits), page (wiki pages), and user (registered and unregistered editors), categorylinks (pages in categories).
DESCRIBE enwiki_p.revision; DESCRIBE enwiki_p.page; DESCRIBE enwiki_p.user; DESCRIBE enwiki_p.categorylinks;
{"resultsets": [{"headers": ["Field", "Type", "Null", "Key", "Default", "Extra"], "rowcount": 14}, {"headers": ["Field", "Type", "Null", "Key", "Default", "Extra"], "rowcount": 13}, {"headers": ["Field", "Type", "Null", "Key", "Default", "Extra"], "rowcount": 16}, {"headers": ["Field", "Type", "Null", "Key", "Default", "Extra"], "rowcount": 7}]}
null
Get first edit to a page from title
Information about the first edit to the page "The Hobbit: The Battle of the Five Armies" on the English Wikipedia. The revision table contains info about the first revision, but not the title of the page. The page table contains the title, but not info about the first rev. Joining the tables using the common keys (rev_page AND page_id) allows you to get all this info in one query.
SELECT rev_page, page_id, page_title, MIN(rev_id) AS first_revision, rev_user_text AS page_creator, rev_timestamp AS first_rev_date FROM revision, page WHERE page_namespace = 0 AND rev_page = page_id AND page_title = "The_Hobbit:_The_Battle_of_the_Five_Armies";
{"resultsets": [{"headers": ["rev_page", "page_id", "page_title", "first_revision", "page_creator", "first_rev_date"], "rowcount": 1}]}
null
Get page creation info for all pages in a category
The first revision, the person who created the page, the date/time the page was created, the title of the page, and the category that all the listed pages are in.
#1 SELECT MIN(rev_id), rev_user_text, rev_user, rev_timestamp, page_title, cl_to #2 FROM enwiki_p.page p #3 INNER JOIN enwiki_p.categorylinks cl ON p.page_id = cl.cl_from #4 INNER JOIN enwiki_p.revision r ON p.page_id = r.rev_page #5 WHERE p.page_namespace = 0 #6 AND cl.cl_to IN ("The_Hobbit_(film_series)") #7 GROUP BY page_id; #LINE 1: declare which database fields (columns) you want to include in your output. #You can include any fields from any of the tables you are joining (in this case: page, categorylinks, revision) #LINE 2: declare which wiki you are pulling data from. #In this case, commonswiki_p. You can find a full list here: https://tools.wmflabs.org/tools-info/?dblist=s1.labsdb #LINE 3: join the page table with the categorylinks table on their COMMON KEY, which is the id of the page. #LINE 4: join the page table with the revision table on their COMMON KEY, which is the id of the page. #LINE 5: specify the numeric namespace(s) of the pages you want to get information for. #There is a list of standard namespaces here: https://en.wikipedia.org/wiki/Wikipedia:Namespace #LINE 6: specify the category(ies) that the pages are in. If you wanted to get pages from multipe categories, #you would write the query the same way: AND cl.cl_to IN ("My_first_category", "Another_category") #LINE 7: specify that you want to return the revision information from the FIRST revision to the page. #Revision ids are sequential, so the first revision to a page will have a lower rev_id number #than all the other edits to that page.
{"resultsets": [{"headers": ["MIN(rev_id)", "rev_user_text", "rev_user", "rev_timestamp", "page_title", "cl_to"], "rowcount": 8}]}
null
Monthly Hobbit edits
Edits to articles in enwiki Category:The_Hobbit_(film_series) grouped by article, month, and year.
SELECT tmp.page_title, EXTRACT(Year from DATE_FORMAT(rev_timestamp,'%Y%m%d%H%i%s')) as `year`, LPAD(EXTRACT(Month from DATE_FORMAT(rev_timestamp,'%Y%m%d%H%i%s')), 2, '0') as `month`, COUNT(rev_id) AS revisions FROM revision r JOIN (SELECT page_id, page_title FROM enwiki_p.page AS p INNER JOIN enwiki_p.categorylinks AS cl ON p.page_id = cl.cl_from WHERE cl.cl_to IN ('The_Hobbit_(film_series)') AND cl.cl_type = 'page' AND p.page_namespace = 0) tmp ON r.rev_page = tmp.page_id GROUP BY tmp.page_title, `year`, `month` ORDER BY tmp.page_title ASC, `year` ASC, `month` ASC;
{"resultsets": [{"headers": ["page_title", "year", "month", "revisions"], "rowcount": 221}]}
null
All images on a page
A list of the images that are on the Wikipedia article "Seattle".
SELECT page_title, il_to FROM enwiki_p.page AS article JOIN enwiki_p.imagelinks AS images_on_pages ON article.page_id = images_on_pages.il_from AND il_from = 11388236;
{"resultsets": [{"headers": ["page_title", "il_to"], "rowcount": 74}]}
null
Pages in a category that need citations
This query uses three JOINs to get you the title of all pages in the "Oral hygiene" category that have at least one "Citation needed" template.
SELECT page_title FROM page JOIN templatelinks ON tl_from = page_id JOIN categorylinks ON cl_from = page_id WHERE cl_to = "Oral_hygiene" AND tl_namespace = 10 AND tl_title = "Citation_needed" AND page_namespace = 0;
{"resultsets": [{"headers": ["page_title"], "rowcount": 11}]}
null
Edits to articles in enwiki Category:Kanye_West grouped by article, month, and year.
null
SELECT tmp.page_title, EXTRACT(Year from DATE_FORMAT(rev_timestamp,'%Y%m%d%H%i%s')) as `year`, LPAD(EXTRACT(Month from DATE_FORMAT(rev_timestamp,'%Y%m%d%H%i%s')), 2, '0') as `month`, COUNT(rev_id) AS revisions FROM revision r JOIN (SELECT page_id, page_title FROM enwiki_p.page AS p INNER JOIN enwiki_p.categorylinks AS cl ON p.page_id = cl.cl_from WHERE cl.cl_to IN ('Kanye_West') AND cl.cl_type = 'page' AND p.page_namespace = 0) tmp ON r.rev_page = tmp.page_id GROUP BY tmp.page_title, `year`, `month` ORDER BY tmp.page_title ASC, `year` ASC, `month` ASC;
{"resultsets": [{"headers": ["page_title", "year", "month", "revisions"], "rowcount": 863}]}
null
Describe the user table
The fields in the user table on english wikipedia
DESCRIBE user;
{"resultsets": [{"headers": ["Field", "Type", "Null", "Key", "Default", "Extra"], "rowcount": 16}]}
null
Describe tables in databased
The fields in the user table on english wikipedia
Describe user;
{"resultsets": [{"headers": ["Field", "Type", "Null", "Key", "Default", "Extra"], "rowcount": 16}]}
null
Page Titles Include "Seattle"
null
SELECT * FROM page WHERE lower(page_title) LIKE ("%seattle%") ;
{"resultsets": [{"headers": ["page_id", "page_namespace", "page_title", "page_restrictions", "page_counter", "page_is_redirect", "page_is_new", "page_random", "page_touched", "page_links_updated", "page_latest", "page_len", "page_content_model"], "rowcount": 226}]}
null
Most recent edits from UW (128.208)
null
select * from recentchanges where rc_user_text like '128.208.%'
{"resultsets": [{"headers": ["rc_id", "rc_timestamp", "rc_cur_time", "rc_user", "rc_user_text", "rc_namespace", "rc_title", "rc_comment", "rc_minor", "rc_bot", "rc_new", "rc_cur_id", "rc_this_oldid", "rc_last_oldid", "rc_type", "rc_source", "rc_patrolled", "rc_ip", "rc_old_len", "rc_new_len", "rc_deleted", "rc_logid", "rc_log_type", "rc_log_action", "rc_params"], "rowcount": 12}]}
null
Hobbit_search_2
search on The Hobbit (film_series) returning only articles--less sloppy
select page_title as article_title, cl_to as article_category from enwiki_p.page as p join enwiki_p.categorylinks as cl on p.page_id = cl.cl_from and cl_to in ("The_Hobbit_(film_series)") and cl_type = "page";
{"resultsets": [{"headers": ["article_title", "article_category"], "rowcount": 9}]}
null
Users grouped by Edits
null
use enwiki_p; select case when user_editcount = 0 then '0' when user_editcount < 5 then '1 - 5' when user_editcount < 10 then '5 - 10' when user_editcount < 50 then '10 - 50' when user_editcount < 100 then '50 - 100' when user_editcount < 500 then '100 - 500' when user_editcount < 1000 then '500 - 1000' when user_editcount < 2000 then '1000 - 2000' when user_editcount < 5000 then '2000 - 5000' else '5000+' end as bucket, count(*) as count from user group by bucket order by count
{"resultsets": [{"headers": ["bucket", "count"], "rowcount": 10}]}
null
All tabels in enwiki_p
use enwiki_p; show tables;
use enwiki_p; show tables;
{"resultsets": [{"headers": ["Tables_in_enwiki_p"], "rowcount": 108}]}
null
Discography pages on fawiki
null
USE fawiki_p; SELECT `page_title` FROM `page` WHERE `page_is_redirect` = 0 AND `page_namespace` = 0 AND (`page_title` LIKE 'ترانه‌شناسی%' OR `page_title` LIKE '%(ترانه‌شناسی%)') GROUP BY `page_title` ORDER BY `page_title` ASC;
{"resultsets": [{"headers": ["page_title"], "rowcount": 79}]}
null
Random list of BLPs
Obtains 500 random BLPs
SELECT page_title FROM page JOIN categorylinks ON cl_from = page_id WHERE cl_to = 'Living_people' AND page_is_redirect = 0 AND page_namespace = 0 AND page_random > RAND() ORDER BY page_random LIMIT 500;
{"resultsets": [{"headers": ["page_title"], "rowcount": 500}]}
null
pt-WP project-tagged articles
Count the number of articles (and talk pages) in Portuguese Wikipedia that are tagged with the "Marca de projeto" template.
USE ptwiki_p; SELECT count(DISTINCT p.page_title) AS num_pages FROM templatelinks tl JOIN page p ON tl.tl_from=p.page_id WHERE p.page_namespace IN (0,1) AND tl_namespace=10 AND tl_title = 'Marca_de_projeto'; SELECT count(DISTINCT page_title) AS num_level4_articles FROM categorylinks JOIN page ON page_id=cl_from WHERE cl_to LIKE '!Artigos\_de\_qualidade\_4%' AND page_namespace IN (0,1); SELECT count(DISTINCT page_title) AS num_level3_articles FROM categorylinks JOIN page ON page_id=cl_from WHERE cl_to LIKE '!Artigos\_de\_qualidade\_3%' AND page_namespace IN (0,1); SELECT count(DISTINCT page_title) AS num_level2_articles FROM categorylinks JOIN page ON page_id=cl_from WHERE cl_to LIKE '!Artigos\_de\_qualidade\_2%' AND page_namespace IN (0,1); SELECT count(DISTINCT page_title) AS num_level1_articles FROM categorylinks JOIN page ON page_id=cl_from WHERE cl_to LIKE '!Artigos\_de\_qualidade\_1%' AND page_namespace IN (0,1);
{"resultsets": [{"headers": ["num_pages"], "rowcount": 1}, {"headers": ["num_level4_articles"], "rowcount": 1}, {"headers": ["num_level3_articles"], "rowcount": 1}, {"headers": ["num_level2_articles"], "rowcount": 1}, {"headers": ["num_level1_articles"], "rowcount": 1}]}
null
CDSW SQL
List of all the databases Quarry has access to
-- SELECT * FROM enwiki_p.user WHERE user_name = "Mdmurbach" -- SELECT page_title AS article_title, cl_to AS article_category FROM enwiki_p.page -- AS p JOIN enwiki_p.categorylinks AS cl -- ON p.page_id = cl.cl_from AND cl_to IN ("The_Hobbit_(film_series)") AND cl_type = "page";
{"resultsets": []}
null
bots in eswiki
null
USE eswiki_p; SELECT rev_user_text Robô, MAX(rev_timestamp) Última_edição FROM revision_userindex WHERE rev_user IN (SELECT ug_user FROM user_groups WHERE ug_group = 'bot') GROUP BY rev_user;
{"resultsets": [{"headers": ["Rob\u00f4", "\u00daltima_edi\u00e7\u00e3o"], "rowcount": 36}]}
null
top 100 eswiki Articles by size
null
USE eswiki_p; select page_title, DATE(page_touched) as ddate, page_len, page_namespace from page where page_len > 102400 and page_namespace = 0 order by page_len desc limit 100
{"resultsets": [{"headers": ["page_title", "ddate", "page_len", "page_namespace"], "rowcount": 100}]}
null
Most thanked users on ptwiki
null
USE ptwiki_p; SELECT log_title, COUNT(*) FROM logging WHERE log_type="thanks" GROUP BY log_title ORDER BY COUNT(*) DESC LIMIT 20;
{"resultsets": [{"headers": ["log_title", "COUNT(*)"], "rowcount": 20}]}
null