query-1cca979d9139c72593eeb6cc80dd335e
(P17)country
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?c (COUNT(DISTINCT ?item) AS ?count) (SAMPLE(?item) as ?sample)
{
{
SELECT ?item ?c {
?item p:P159 / pq:P969 [] ; wdt:P17 ?c
}
}
UNION
{
SELECT ?item ?c {
?item p:P159 ?stmt .
?stmt pq:P969 [] ; pq:P17 ?c
}
}
UNION
{
SELECT ?item ?c {
?item p:P159 ?stmt .
?stmt pq:P969 [] .
?stmt ps:P159 / wdt:P17 ?c
}
}
}
GROUP BY ?c
ORDER BY DESC(?count)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?c"):::projected
v5("?count")
v2("?item"):::projected
v5("?sample")
v4("?stmt")
a2((" "))
a3((" "))
a4((" "))
a1((" "))
a5((" "))
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
v2 --"p:P159"--> v4
v4 --"p:qualifier/P969"--> a4
v4 --"p:statement/P159"--> a5
a5 --"p:direct/P17"--> v3
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:P159"--> v4
v4 --"p:qualifier/P969"--> a3
v4 --"p:qualifier/P17"--> v3
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:P159"--> a1
a1 --"p:qualifier/P969"--> a2
v2 --"p:direct/P17"--> v3
end
union0r <== or ==> union0l
end
bind2[/"count(?item)"/]
v2 --o bind2
bind2 --as--o v5
bind3[/"sample(?item)"/]
v2 --o bind3
bind3 --as--o v5