query-da6d913714d1275cb587aa4218ec159c

rq turtle/ttl

Propertiesinstance of (P31)subclass of (P279)image (P18)language of work or name (P407)collection (P195)end time (P582)inventory number (P217)

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?q ?qLabel (GROUP_CONCAT(DISTINCT ?collplusinv; separator=" !!! ") AS ?where) (GROUP_CONCAT(DISTINCT ?lang; separator=" ") AS ?languages) ?linkcount (SAMPLE(?image) AS ?image)
WHERE { {SELECT ?q (COUNT(?sitelink) AS ?linkcount) WHERE { ?q (wdt:P31/wdt:P279*) wd:Q87167. OPTIONAL {?sitelink schema:about ?q} }
   GROUP BY ?q  }
?q p:P195 ?s. ?s ps:P195 ?collection . MINUS {?s pq:P582 []}.
      MINUS {?s ps:P195 wd:Q1322278 }
OPTIONAL{ ?s pq:P217 ?inventory}
OPTIONAL{ ?q wdt:P18 ?image }
BIND( IF(BOUND(?inventory), CONCAT(STR(?collection)," ",?inventory), STR(?collection)) AS ?collplusinv).
 SERVICE wikibase:label {
   bd:serviceParam wikibase:language "en,fr,it,de,es,ru,bg,ca,cs,nl,zh,ja".
   ?q rdfs:label ?qLabel.
 }
OPTIONAL{ ?q wdt:P407 ?lang }
# other props: part of, exemplar
}
GROUP BY ?q ?qLabel ?linkcount
ORDER BY DESC(?linkcount)

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?collection") v8("?collplusinv"):::projected v13("?image"):::projected v6("?inventory") v10("?lang"):::projected v12("?languages") v4("?linkcount"):::projected v2("?q"):::projected v9("?qLabel"):::projected v4("?s") v3("?sitelink") v11("?where") a2((" ")) a1((" ")) c8(["wd:Q1322278"]):::iri c3(["wd:Q87167"]):::iri c12(["bd:serviceParam"]):::iri c14(["en,fr,it,de,es,ru,bg,ca,cs,nl,zh,ja"]):::literal v2 --"p:direct/P31"--> a1 a1 --"p:direct/P279"--> c3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."schema:about".-> v2 end bind1[/"count(?sitelink)"/] v3 --o bind1 bind1 --as--o v4 v2 --"p:P195"--> v4 v4 --"p:statement/P195"--> v5 subgraph minus2["MINUS"] style minus2 stroke-width:6px,fill:pink,stroke:red; v4 --"p:qualifier/P582"--> a2 end subgraph minus3["MINUS"] style minus3 stroke-width:6px,fill:pink,stroke:red; v4 --"p:statement/P195"--> c8 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:qualifier/P217".-> v6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P18".-> v13 end bind4[/"if(bound(?inventory),concat(str(?collection),' ',?inventory),str(?collection))"/] v6 --o bind4 v5 --o bind4 bind4 --as--o v8 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 v2 --"rdfs:label"--> v9 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P407".-> v10 end bind8[/"?collplusinv"/] v8 --o bind8 bind8 --as--o v11 bind9[/"?lang"/] v10 --o bind9 bind9 --as--o v12 bind10[/"sample(?image)"/] v13 --o bind10 bind10 --as--o v13