query-9c675892bc5ce21c518e79ff69ecff50
Types of museums, by number of instances
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT DISTINCT ?type
(COUNT(DISTINCT ?instance) AS ?count)
?Label_en
(group_concat(distinct ?Alias_en;separator="; ") as ?Aliases_en) #Concatenate the values in order not to get several rows per type.
(group_concat(distinct ?institutionType1_en;separator="; ") as ?institutionTypes1_en)
(group_concat(distinct ?institutionType2_en;separator="; ") as ?institutionTypes2_en)
(group_concat(distinct ?institutionType3_en;separator="; ") as ?institutionTypes3_en)
(group_concat(distinct ?institutionType4_en;separator="; ") as ?institutionTypes4_en)
WHERE {
?type wdt:P279* wd:Q33506 .
OPTIONAL { ?instance wdt:P31 ?type }
OPTIONAL { ?type rdfs:label ?Label_en . FILTER (lang(?Label_en) = "en") }
OPTIONAL { ?type skos:altLabel ?Alias_en . FILTER (lang(?Alias_en) = "en") }
OPTIONAL { ?type wdt:P279+ ?institutionType1 . ?institutionType1 wdt:P279/^wdt:P279 wd:Q33506 . ?institutionType1 rdfs:label ?institutionType1_en . FILTER (lang(?institutionType1_en) = "en") }
OPTIONAL { ?type wdt:P279+ ?institutionType1 . ?institutionType1 wdt:P279/^wdt:P279 wd:Q166118 . ?institutionType1 rdfs:label ?institutionType1_en . FILTER (lang(?institutionType1_en) = "en") }
OPTIONAL { ?type wdt:P279+ ?institutionType1 . ?institutionType1 wdt:P279/^wdt:P279 wd:Q7075 . ?institutionType1 rdfs:label ?institutionType1_en . FILTER (lang(?institutionType1_en) = "en") }
OPTIONAL { ?type wdt:P279+ ?institutionType2 . ?institutionType2 wdt:P279 wd:Q33506 . ?institutionType2 rdfs:label ?institutionType2_en . FILTER (lang(?institutionType2_en) = "en") }
OPTIONAL { ?type wdt:P279+ ?institutionType2 . ?institutionType2 wdt:P279 wd:Q166118 . ?institutionType2 rdfs:label ?institutionType2_en . FILTER (lang(?institutionType2_en) = "en") }
OPTIONAL { ?type wdt:P279+ ?institutionType2 . ?institutionType2 wdt:P279 wd:Q7075 . ?institutionType2 rdfs:label ?institutionType2_en . FILTER (lang(?institutionType2_en) = "en") }
OPTIONAL { ?type wdt:P279+ ?institutionType3 . ?institutionType3 wdt:P279/wdt:P279 wd:Q33506 . ?institutionType3 rdfs:label ?institutionType3_en . FILTER (lang(?institutionType3_en) = "en") }
OPTIONAL { ?type wdt:P279+ ?institutionType3 . ?institutionType3 wdt:P279/wdt:P279 wd:Q166118 . ?institutionType3 rdfs:label ?institutionType3_en . FILTER (lang(?institutionType3_en) = "en") }
OPTIONAL { ?type wdt:P279+ ?institutionType3 . ?institutionType3 wdt:P279/wdt:P279 wd:Q7075 . ?institutionType3 rdfs:label ?institutionType3_en . FILTER (lang(?institutionType3_en) = "en") }
OPTIONAL { ?type wdt:P279+ ?institutionType4 . ?institutionType4 wdt:P279/wdt:P279/wdt:P279 wd:Q33506 . ?institutionType4 rdfs:label ?institutionType4_en . FILTER (lang(?institutionType4_en) = "en") }
OPTIONAL { ?type wdt:P279+ ?institutionType4 . ?institutionType4 wdt:P279/wdt:P279/wdt:P279 wd:Q166118 . ?institutionType4 rdfs:label ?institutionType4_en . FILTER (lang(?institutionType4_en) = "en") }
OPTIONAL { ?type wdt:P279+ ?institutionType4 . ?institutionType4 wdt:P279/wdt:P279/wdt:P279 wd:Q7075 . ?institutionType4 rdfs:label ?institutionType4_en . FILTER (lang(?institutionType4_en) = "en") }
}
GROUP BY ?type #List all the variables for which the values are not concatenated!
?count
?Label_en
ORDER BY DESC(?count)