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
Derethor
.
Toggle Highlighting
SQL
#List of countries ordered by the number of their cities with female mayor #added before 2016-10 SELECT ?country ?countryLabel (count(*) AS ?count) WHERE { ?city wdt:P31/wdt:P279* wd:Q515 . # find instances of subclasses of city ?city p:P6 ?statement . # with a P6 (head of goverment) statement ?statement ps:P6 ?mayor . # ... that has the value ?mayor ?mayor wdt:P21 wd:Q6581072 . # ... where the ?mayor has P21 (sex or gender) female FILTER NOT EXISTS { ?statement pq:P582 ?x } # ... but the statement has no P582 (end date) qualifier ?city wdt:P17 ?country . # Also find the country of the city # If available, get the "ru" label of the country, use "en" as fallback: SERVICE wikibase:label { bd:serviceParam wikibase:language "ru,en" . } } GROUP BY ?country ?countryLabel ORDER BY DESC(?count) 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...