query-35646cae51e6b9e2774c48df39f17f63

rq turtle/ttl

title: Mix of P159, P115 & P276 used in sport event SELECT ?value ?ct ?sampleitem ?sampleitemLabel WHERE { { SELECT ?value (count() as ?ct) (SAMPLE(?item) as ?sampleitem) WHERE { ?item (wdt:P31/(wdt:P279)) wd:Q16510064. # àmbit sobre el que es vol explorar optional { ?item wdt:P159 ?p159.} # propietats a analitzar si hi són optional { ?item wdt:P115 ?p115.} optional { ?item wdt:P276 ?p276.} BIND(IF(BOUND(?p159),"P159","") AS ?seu). # genera text per cada propietat existent BIND(IF(BOUND(?p115),"P115","") AS ?sta). BIND(IF(BOUND(?p276),"P276","") AS ?loc). bind(CONCAT(?seu, "-", ?sta, "-", ?loc) as ?value). #crear un codi amb els textos concatenats } GROUP BY ?value ORDER BY DESC(?ct) LIMIT 10 } SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } } ORDER BY DESC(?ct) ASC(?value)

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#>
#title: Mix of P159, P115 & P276 used in sport event
SELECT ?value ?ct ?sampleitem ?sampleitemLabel
WHERE
{
  {
    SELECT ?value (count(*) as ?ct) (SAMPLE(?item) as ?sampleitem)
    WHERE
    {
  ?item (wdt:P31/(wdt:P279*)) wd:Q16510064.    # àmbit sobre el que es vol explorar
  optional { ?item wdt:P159 ?p159.}            # propietats a analitzar si hi són
  optional { ?item wdt:P115 ?p115.}
  optional { ?item wdt:P276 ?p276.}
  BIND(IF(BOUND(?p159),"P159","") AS ?seu).    # genera text per cada propietat existent
  BIND(IF(BOUND(?p115),"P115","") AS ?sta).
  BIND(IF(BOUND(?p276),"P276","") AS ?loc).
  bind(CONCAT(?seu, "-", ?sta, "-", ?loc) as ?value).  #crear un codi amb els textos concatenats
    }
    GROUP BY ?value
    ORDER BY DESC(?ct)
    LIMIT 10  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
ORDER BY DESC(?ct) ASC(?value)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v10("?ct"):::projected v3("?item") v9("?loc") v5("?p115") v4("?p159") v6("?p276") v10("?sampleitem"):::projected v7("?seu") v8("?sta") v10("?value"):::projected a1((" ")) c8(["bd:serviceParam"]):::iri c10(["#91;AUTO_LANGUAGE#93;,en"]):::literal c3(["wd:Q16510064"]):::iri v3 --"wdt:P31"--> a1 a1 --"wdt:P279"--> c3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P159".-> v4 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P115".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P276".-> v6 end bind0[/"if(bound(?p159),'P159','')"/] v4 --o bind0 bind0 --as--o v7 bind1[/"if(bound(?p115),'P115','')"/] v5 --o bind1 bind1 --as--o v8 bind2[/"if(bound(?p276),'P276','')"/] v6 --o bind2 bind2 --as--o v9 bind3[/"concat(?seu,'-',?sta,'-',?loc)"/] v7 --o bind3 v8 --o bind3 v9 --o bind3 bind3 --as--o v10 bind6[/"count(*)"/] bind6 --as--o v10 bind7[/"sample(?item)"/] v3 --o bind7 bind7 --as--o v10 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end