query-e44d9017eb1444b5e656076e44df0f98

rq turtle/ttl

TODO

Use at

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
SELECT ?s ?categories (COUNT(?site1a) AS ?count) (GROUP_CONCAT(?site1b;SEPARATOR=', ') AS ?sites) WHERE {
   {
SELECT ?site1a (COUNT(*) AS ?count) (SUM(?x) AS ?s) {
  { ?site1 schema:about wd:Q5645580 . BIND(STRBEFORE(STR(?site1),'.org') AS ?site1a) BIND(1 AS ?x) }
  UNION
  { ?site1 schema:about wd:Q6010682 . BIND(STRBEFORE(STR(?site1),'.org') AS ?site1a) BIND(10 AS ?x) }
  UNION
  { ?site1 schema:about wd:Q9703849  . BIND(STRBEFORE(STR(?site1),'.org') AS ?site1a) BIND(100 AS ?x) }
}
GROUP BY ?site1a
ORDER BY ?site1a
}  BIND(STRAFTER(?site1a,'//') AS ?site1b)
  BIND(IF(?s=111,'All three categories',IF(?s=110,'All but Q5645580',IF(?s=101,'All but Q6010682',IF(?s=11,'All but Q9703849',IF(?s=1,'Only Q5645580',IF(?s=10,'Only Q6010682',IF(?s=100,'Only Q9703849',''))))))) AS ?categories)
}
GROUP BY ?s ?categories
ORDER BY DESC(?s)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v7("?categories"):::projected v8("?count") v6("?s"):::projected v3("?site1") v5("?site1a"):::projected v6("?site1b"):::projected v8("?sites") v5("?x") c2(["wd:Q5645580"]):::iri c3(["wd:Q6010682"]):::iri c4(["wd:Q9703849"]):::iri subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; subgraph union1[" Union "] subgraph union1l[" "] style union1l fill:#abf,stroke-dasharray: 3 3; v3 --"schema:about"--> c4 bind0[/"substring-before(str(?site1),'.org')"/] v3 --o bind0 bind0 --as--o v5 bind1[/"'100^^xsd:integer'"/] bind1 --as--o v5 end subgraph union1r[" "] style union1r fill:#abf,stroke-dasharray: 3 3; v3 --"schema:about"--> c3 bind2[/"substring-before(str(?site1),'.org')"/] v3 --o bind2 bind2 --as--o v5 bind3[/"'10^^xsd:integer'"/] bind3 --as--o v5 end union1r <== or ==> union1l end end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v3 --"schema:about"--> c2 bind4[/"substring-before(str(?site1),'.org')"/] v3 --o bind4 bind4 --as--o v5 bind5[/"'1^^xsd:integer'"/] bind5 --as--o v5 end union0r <== or ==> union0l end bind8[/"count(*)"/] bind8 --as--o v8 bind9[/"sum(?x)"/] v5 --o bind9 bind9 --as--o v6 bind10[/"substring-after(?site1a,'//')"/] v5 --o bind10 bind10 --as--o v6 bind11[/"if(?s = '111^^xsd:integer','All three categories',if(?s = '110^^xsd:integer','All but Q5645580',if(?s = '101^^xsd:integer','All but Q6010682',if(?s = '11^^xsd:integer','All but Q9703849',if(?s = '1^^xsd:integer','Only Q5645580',if(?s = '10^^xsd:integer','Only Q6010682',if(?s = '100^^xsd:integer','Only Q9703849','')))))))"/] v6 --o bind11 bind11 --as--o v7 bind14[/"count(?site1a)"/] v5 --o bind14 bind14 --as--o v8 bind15[/"?site1b"/] v6 --o bind15 bind15 --as--o v8