query-2458b1c2749a5a25e538192499360771

rq turtle/ttl

Count by US state of a state, then the query will be like this: (P131)located in the administrative territorial entity of a county which are (P131)located in the administrative territorial entity I want to list company headquarters by US state. Most cities are

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#>
#defaultView:BarChart
SELECT ?entity2Label (COUNT(?entity2) AS ?count) WHERE {
  ?item wdt:P31 wd:Q46970.
  ?item wdt:P159 ?hq.
  ?hq wdt:P131 ?entity.
  ?entity wdt:P131 ?entity2 .
  ?entity2 wdt:P17 wd:Q30 .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE]". }
}
GROUP BY ?entity2Label
ORDER BY ?count

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?count") v4("?entity") v5("?entity2"):::projected v3("?hq") v2("?item") c8(["bd:serviceParam"]):::iri c2(["wd:Q46970"]):::iri c10(["#91;AUTO_LANGUAGE#93;"]):::literal c6(["wd:Q30"]):::iri v2 --"wdt:P31"--> c2 v2 --"wdt:P159"--> v3 v3 --"wdt:P131"--> v4 v4 --"wdt:P131"--> v5 v5 --"wdt:P17"--> c6 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end bind1[/"count(?entity2)"/] v5 --o bind1 bind1 --as--o v6