query-ffaf385737e71f1495af37edd6061b47

rq turtle/ttl

Categories de premis per nombre de premiats a Wikidata SELECT DISTINCT ?premi ?catpral ?categoriapral ?catpremiats ?categoriapremiats (COUNT(?persona) AS ?numpers) WHERE { ?persona wdt:P31 wd:Q5. ?persona wdt:P166 ?premi. ?premi wdt:P910|wdt:P2517 ?cat. ?categoria schema:about ?cat. ?categoria schema:isPartOf https://ca.wikipedia.org/. OPTIONAL { ?premi wdt:P910 ?catpral. OPTIONAL { ?categoriapral schema:about ?catpral. ?categoriapral schema:isPartOf https://ca.wikipedia.org/. } } OPTIONAL { ?premi wdt:P2517 ?catpremiats. OPTIONAL { ?categoriapremiats schema:about ?catpremiats. ?categoriapremiats schema:isPartOf https://ca.wikipedia.org/. } } } GROUP BY ?premi ?catpral ?categoriapral ?catpremiats ?categoriapremiats ORDER BY DESC(?numpers)

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
# Categories de premis per nombre de premiats a Wikidata
SELECT DISTINCT ?premi ?catpral ?categoriapral ?catpremiats ?categoriapremiats (COUNT(?persona) AS ?numpers)
WHERE {
  ?persona wdt:P31 wd:Q5.
  ?persona wdt:P166 ?premi.
  ?premi wdt:P910|wdt:P2517 ?cat.
    ?categoria schema:about ?cat.
    ?categoria schema:isPartOf <https://ca.wikipedia.org/>.
  OPTIONAL {
    ?premi wdt:P910 ?catpral.
  OPTIONAL {
    ?categoriapral schema:about ?catpral.
    ?categoriapral schema:isPartOf <https://ca.wikipedia.org/>.
  }
    }
  OPTIONAL {
    ?premi wdt:P2517 ?catpremiats.
  OPTIONAL {
    ?categoriapremiats schema:about ?catpremiats.
    ?categoriapremiats schema:isPartOf <https://ca.wikipedia.org/>.
  }
    }
}
GROUP BY ?premi ?catpral ?categoriapral ?catpremiats ?categoriapremiats
ORDER BY DESC(?numpers)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?cat") v5("?categoria") v7("?categoriapral"):::projected v9("?categoriapremiats"):::projected v6("?catpral"):::projected v8("?catpremiats"):::projected v10("?numpers") v2("?persona"):::projected v3("?premi"):::projected c2(["wd:Q5"]):::iri c8([https://ca.wikipedia.org/]):::iri v2 --"wdt:P31"--> c2 v2 --"wdt:P166"--> v3 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P2517"--> v4 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"wdt:P910"--> v4 end union0r <== or ==> union0l end v5 --"schema:about"--> v4 v5 --"schema:isPartOf"--> c8 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P910".-> v6 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v7 -."schema:about".-> v6 v7 --"schema:isPartOf"--> c8 end end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P2517".-> v8 subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v9 -."schema:about".-> v8 v9 --"schema:isPartOf"--> c8 end end bind1[/"count(?persona)"/] v2 --o bind1 bind1 --as--o v10