query-b86d83315242d68da233a0efcd4ba592

rq turtle/ttl

countries without hospitals SELECT ?country ?countryLabel (COUNT(?entity) as ?count) (SAMPLE(?entity) as ?sample) WHERE { {
?entity wdt:P31/wdt:P279* wd:Q16917 ; wdt:P17 ?country .
} UNION {
SELECT DISTINCT ?country { ?item wdt:P360 wd:Q16917 ; wdt:P17 ?country . } } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } GROUP BY ?country ?countryLabel HAVING (?count = 0) ORDER BY ?countryLabel

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#countries without hospitals
SELECT ?country ?countryLabel (COUNT(?entity) as ?count) (SAMPLE(?entity) as ?sample) 
WHERE 
{
  {     
      ?entity wdt:P31/wdt:P279* wd:Q16917 ; wdt:P17 ?country .  
  } 
  UNION 
  {    
      SELECT DISTINCT ?country  { ?item wdt:P360 wd:Q16917 ; wdt:P17 ?country .  }
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} 
GROUP BY ?country ?countryLabel
HAVING (?count = 0) 
ORDER BY ?countryLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?count") v4("?country"):::projected v1("?countryLabel"):::projected v3("?entity"):::projected v5("?item") v6("?sample") a1((" ")) c8(["bd:serviceParam"]):::iri c4(["wd:Q16917"]):::iri c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["?count = '0^^xsd:integer'"]] f0 --> v6 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v5 --"wdt:P360"--> c4 v5 --"wdt:P17"--> v4 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c4 v3 --"wdt:P17"--> v4 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end bind3[/"count(?entity)"/] v3 --o bind3 bind3 --as--o v6 bind4[/"sample(?entity)"/] v3 --o bind4 bind4 --as--o v6