query-1763b2a9e8d3f4230595a4cb5798bf99

rq turtle/ttl

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 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 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 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 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 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 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 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 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 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

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#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

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?city") v7("?count") v6("?country"):::projected v5("?mayor") v2("?statement") v3("?x") a1((" ")) c8(["wd:Q6581072"]):::iri c13(["ru,en"]):::literal c11(["bd:serviceParam"]):::iri c4(["wd:Q515"]):::iri f0[["not "]] subgraph f0e0["Exists Clause"] e0v1 --"p:qualifier/P582"--> e0v2 e0v1("?statement"):::projected e0v2("?x"):::projected end f0--EXISTS--> f0e0 f0 --> v2 f0 --> c1 f0 --> v3 v2 --"p:qualifier/P582"--> v3 v4 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c4 v4 --"p:P6"--> v2 v2 --"p:statement/P6"--> v5 v5 --"p:direct/P21"--> c8 v4 --"p:direct/P17"--> v6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c11 --"wikibase:language"--> c13 end bind2[/"count(*)"/] bind2 --as--o v7