query-c8bbcb38f19a912e0c366cf97d47fbd4

rq turtle/ttl

COUNT, DISTINCT, GROUP BY SELECT ?item ?itemLabel (COUNT (DISTINCT ?order ) AS ?count) WHERE {

?item wdt:P166 ?rank . ?rank wdt:P361 ?order .

{?rank wdt:P361 wd:Q23657078 . } UNION {?rank wdt:P361 wd:Q639358 . }

SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],pt,en". } }

GROUP BY ?item ?itemLabel

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#>
#COUNT, DISTINCT, GROUP BY
SELECT ?item ?itemLabel (COUNT (DISTINCT ?order ) AS ?count) WHERE {

  ?item  wdt:P166  ?rank  .
  ?rank  wdt:P361  ?order .

 {?rank   wdt:P361  wd:Q23657078  . } 
UNION
 {?rank  wdt:P361  wd:Q639358 . }

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],pt,en". }
 }

GROUP BY ?item ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?count") v1("?item"):::projected v3("?order"):::projected v2("?rank") c6(["bd:serviceParam"]):::iri c4(["wd:Q639358"]):::iri c3(["wd:Q23657078"]):::iri c8(["#91;AUTO_LANGUAGE#93;,pt,en"]):::literal v1 --"wdt:P166"--> v2 v2 --"wdt:P361"--> v3 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P361"--> c4 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v2 --"wdt:P361"--> c3 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end bind1[/"count(?order)"/] v3 --o bind1 bind1 --as--o v4