query-2eca79062182d037f85260c1618f7eb8
The query for WDQS could look like this:
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 rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?work ?workLabel ?typeLabel ?inception ?published ?instruments ?tonalityLabel ?external ?sitelinks {
{ SELECT
?work
(SAMPLE(?type) AS ?type)
(MIN(?inception) AS ?inception)
(MIN(?published) AS ?published)
(GROUP_CONCAT(DISTINCT ?instrumentLabel; separator=', ') AS ?instruments)
(SAMPLE(?tonality) AS ?tonality)
(COUNT(DISTINCT ?wdt) + COUNT(DISTINCT ?catalogue) AS ?external)
{
?work wdt:P86 wd:Q1268;
wdt:P31 ?type .
?type wdt:P279* wd:Q2188189 .
OPTIONAL { ?work wdt:P571 ?inception } .
OPTIONAL { ?work wdt:P577 ?published } .
OPTIONAL { ?work wdt:P826 ?tonality } .
OPTIONAL { ?work wdt:P870 ?instrument } .
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en" .
?instrument rdfs:label ?instrumentLabel .
} .
OPTIONAL {
?work p:P528 [ pq:P972 ?catalogue ] .
FILTER( ?catalogue IN ( wd:Q385271, wd:Q16749676, wd:Q16749680, wd:Q16747642 ) ) .
} .
OPTIONAL {
?work ?wdt [] .
?wdt ^wikibase:directClaim/wikibase:propertyType wikibase:ExternalId .
} .
} GROUP BY ?work } .
OPTIONAL { ?work wikibase:sitelinks ?sitelinks } .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } .
} ORDER BY ?inception
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v10("?_anon_42b5416610844a34809f33a099ae9de198309")
v11("?_anon_42b5416610844a34809f33a099ae9de198310")
v2("?catalogue")
v13("?external"):::projected
v12("?inception"):::projected
v7("?instrument")
v8("?instrumentLabel")
v12("?instruments"):::projected
v12("?published"):::projected
v14("?sitelinks"):::projected
v13("?tonality")
v12("?type")
v9("?wdt")
v3("?work"):::projected
a2((" "))
a1((" "))
a3((" "))
c17(["en"]):::literal
c23(["wikibase:ExternalId"]):::iri
c9(["wd:Q2188189"]):::iri
c15(["bd:serviceParam"]):::iri
c6(["wd:Q1268"]):::iri
v3 --"p:direct/P86"--> c6
v3 --"p:direct/P31"--> v12
v12 --"p:direct/P279"--> c9
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P571".-> v12
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P577".-> v12
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P826".-> v13
end
subgraph optional3["(optional)"]
style optional3 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P870".-> v7
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c15 --"wikibase:language"--> c17
v7 --"rdfs:label"--> v8
end
subgraph optional4["(optional)"]
style optional4 fill:#bbf,stroke-dasharray: 5 5;
a1 -."p:qualifier/P972".-> v2
v3 --"p:P528"--> a1
end
subgraph optional5["(optional)"]
style optional5 fill:#bbf,stroke-dasharray: 5 5;
v3 -->v9--> a2
a3 -."wikibase:directClaim".-> v9
a3 --"wikibase:propertyType"--> c23
end
bind7[/"count(?wdt)"/]
v9 --o bind7
bind7 --as--o v10
bind8[/"count(?catalogue)"/]
v2 --o bind8
bind8 --as--o v11
bind9[/"sample(?type)"/]
v12 --o bind9
bind9 --as--o v12
bind10[/"min(?inception)"/]
v12 --o bind10
bind10 --as--o v12
bind11[/"min(?published)"/]
v12 --o bind11
bind11 --as--o v12
bind12[/"?instrumentLabel"/]
v8 --o bind12
bind12 --as--o v12
bind13[/"sample(?tonality)"/]
v13 --o bind13
bind13 --as--o v13
bind14[/" + "/]
null --o bind14
null --o bind14
bind14 --as--o v13
subgraph optional6["(optional)"]
style optional6 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wikibase:sitelinks".-> v14
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c15 --"wikibase:language"--> c17
end