User:Smalyshev (WMF)/TestQ
- Items used: city (Q515), female (Q6581072)
- Properties used: instance of (P31), subclass of (P279), sex or gender (P21), population (P1082), head of government (P6), end time (P582)
SELECT DISTINCT ?city ?cityLabel ?mayor ?mayorLabel
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
# Now select the population value of the ?city
# (wdt: properties use only statements of "preferred" rank if any, usually meaning "current population")
?city wdt:P1082 ?population .
# Optionally, find English labels for city and mayor:
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
}
}
ORDER BY DESC(?population)
LIMIT 10
- Properties used: net worth (P2218)
SELECT ?item ?itemLabel ?billions
WHERE
{
?item wdt:P2218 ?worth.
FILTER(?worth>1000000000).
BIND(?worth/1000000000 AS ?billions).
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY DESC(?billions)