query-02e7ff2a8df160805fa3833570ef15bb

rq turtle/ttl

Destroyer classes comparing expected and actual member counts

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#>
SELECT DISTINCT ?class ?classLabel (COUNT(?item) AS ?items) ?total WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
  ?class wdt:P31 wd:Q559026. # ship class
  ?class wdt:P279 wd:Q174736. # battlecruiser
  ?class wdt:P137 wd:Q172771. # Royal Navy
  OPTIONAL {  ?class wdt:P1092 ?total}
  ?item wdt:P289 ?class.
} 
GROUP BY ?class ?total ?classLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?class"):::projected v3("?item"):::projected v4("?items") v2("?total"):::projected c2(["bd:serviceParam"]):::iri c4(["#91;AUTO_LANGUAGE#93;"]):::literal c8(["wd:Q174736"]):::iri c6(["wd:Q559026"]):::iri c10(["wd:Q172771"]):::iri subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c2 --"wikibase:language"--> c4 end v1 --"wdt:P31"--> c6 v1 --"wdt:P279"--> c8 v1 --"wdt:P137"--> c10 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."wdt:P1092".-> v2 end v3 --"wdt:P289"--> v1 bind1[/"count(?item)"/] v3 --o bind1 bind1 --as--o v4