query-68ddfd01b03eb705ffccd6c8b47e36f9
Stars in flag versus fertility
Use at
- https://query.wikidata.org/sparql
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#>
SELECT ?iso ?countryLabel (SUM(?stars) as ?stars) ?fertility WHERE {
{SELECT DISTINCT ?country ?iso WHERE {
VALUES ?countrytypes {wd:Q6256 wd:Q3624078} # country and sovereign state
?country wdt:P31 ?countrytypes ; wdt:P298 ?iso
MINUS {?country wdt:P576 []} # Not dissolved
} }
?country wdt:P163 ?flag.
OPTIONAL{
?flag p:P180 [ps:P180 ?feature ; pq:P1114 ?stars] . # quantity of feature
?feature wdt:P279? wd:Q836708 # type of star polygon
}
OPTIONAL { ?country wdt:P4841 ?fertility }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en". }
} GROUP BY ?iso ?countryLabel ?fertility
ORDER BY DESC(?stars) ?countryLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?country")
v2("?countryLabel"):::projected
v3("?countrytypes")
v7("?feature")
v8("?fertility"):::projected
v6("?flag")
v5("?iso"):::projected
v9("?stars"):::projected
a1((" "))
a2((" "))
c8(["wd:Q836708"]):::iri
c14(["#91;AUTO_LANGUAGE#93;,mul,en"]):::literal
c12(["bd:serviceParam"]):::iri
bind0[/VALUES ?countrytypes/]
bind0-->v3
bind00(["wd:Q6256"])
bind00 --> bind0
bind01(["wd:Q3624078"])
bind01 --> bind0
v4 --"p:direct/P31"--> v3
v4 --"p:direct/P298"--> v5
subgraph minus1["MINUS"]
style minus1 stroke-width:6px,fill:pink,stroke:red;
v4 --"p:direct/P576"--> a1
end
v4 --"p:direct/P163"--> v6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
a2 -."p:statement/P180".-> v7
a2 --"p:qualifier/P1114"--> v9
v6 --"p:P180"--> a2
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v7 --"p:direct/P279"--> c8
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
end
union0r <== or ==> union0l
end
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v4 -."p:direct/P4841".-> v8
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c12 --"wikibase:language"--> c14
end
bind3[/"sum(?stars)"/]
v9 --o bind3
bind3 --as--o v9