query-8c3ef63877975807d0b75b060aba22db
List of works in the collection of the Bavarian State Painting Collections or a part thereof SELECT ?item ?itemLabel (COUNT(DISTINCT ?sitelink) AS ?sitelinkno) ?invno # ?itemDescription # <- does not work, if activated and grouped by reduces the number of results WHERE { { ?item wdt:P195 wd:Q812285. } UNION { ?item wdt:P195 [ wdt:P361 wd:Q812285 ]. } OPTIONAL { ?sitelink schema:about ?item. }
OPTIONAL { ?item schema:description ?itemDescription. }
OPTIONAL { ?item p:P217 ?invnostatement. ?invnostatement ps:P217 ?invno. ?invnostatement pq:P195 wd:Q812285. } # BStGS invnos SERVICE wikibase:label { bd:serviceParam wikibase:language "en,de,fr,it,es,pt,ca,la" . } } GROUP BY ?item ?itemLabel ?invno ORDER BY DESC(?sitelinkno)
Use at
- https://query.wikidata.org/sparql
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 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#>
# List of works in the collection of the Bavarian State Painting Collections or a part thereof
SELECT ?item ?itemLabel (COUNT(DISTINCT ?sitelink) AS ?sitelinkno) ?invno # ?itemDescription # <- does not work, if activated and grouped by reduces the number of results
WHERE
{
{ ?item wdt:P195 wd:Q812285. }
UNION
{ ?item wdt:P195 [ wdt:P361 wd:Q812285 ]. }
OPTIONAL { ?sitelink schema:about ?item. }
# OPTIONAL { ?item schema:description ?itemDescription. }
OPTIONAL {
?item p:P217 ?invnostatement.
?invnostatement ps:P217 ?invno.
?invnostatement pq:P195 wd:Q812285.
} # BStGS invnos
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,de,fr,it,es,pt,ca,la" . }
}
GROUP BY ?item ?itemLabel ?invno
ORDER BY DESC(?sitelinkno)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?invno"):::projected
v4("?invnostatement")
v2("?item"):::projected
v3("?sitelink"):::projected
v6("?sitelinkno")
a1((" "))
c9(["bd:serviceParam"]):::iri
c11(["en,de,fr,it,es,pt,ca,la"]):::literal
c2(["wd:Q812285"]):::iri
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
a1 --"p:direct/P361"--> c2
v2 --"p:direct/P195"--> a1
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v2 --"p:direct/P195"--> c2
end
union0r <== or ==> union0l
end
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."schema:about".-> v2
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v2 -."p:P217".-> v4
v4 --"p:statement/P217"--> v5
v4 --"p:qualifier/P195"--> c2
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c9 --"wikibase:language"--> c11
end
bind1[/"count(?sitelink)"/]
v3 --o bind1
bind1 --as--o v6