query-3a4c7dd04c204c708ad98bb390ac02f0
I need a help search P17 with specific countries.) It seems I set P17 more than one country, it'll search not only these countries. Q113976681, not like Q5100224. but when I search these countries at querybuilder or "haswbstatement" etc, other countries are searched too. I want search about P17 with only these three countries(like only Q884, Q148, Q17 with P17I want search and I tried make query, but it's not working. can anyone make query for help me?
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 p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?count
WHERE
{
{
SELECT ?item (COUNT(DISTINCT ?country) AS ?count) WHERE {
?item p:P17 wd:Q17.
?item p:P17 wd:Q148.
?item p:P17 wd:Q884.
?item wdt:P17 ?country .
}
GROUP BY ?item
}
FILTER ( ?count = 3 )
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]" . }
}
ORDER BY DESC(?count) ?itemL
LIMIT 10
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?count"):::projected
v4("?country")
v3("?item"):::projected
v2("?itemL")
c3(["wd:Q17"]):::iri
c4(["wd:Q148"]):::iri
c5(["wd:Q884"]):::iri
c8(["bd:serviceParam"]):::iri
c10(["#91;AUTO_LANGUAGE#93;"]):::literal
f0[["?count = '3^^xsd:integer'"]]
f0 --> v5
v3 --"p:P17"--> c3
v3 --"p:P17"--> c4
v3 --"p:P17"--> c5
v3 --"p:direct/P17"--> v4
bind2[/"count(?country)"/]
v4 --o bind2
bind2 --as--o v5
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c8 --"wikibase:language"--> c10
end