query-0c585e36d757804c687738780c1e902e

rq turtle/ttl

List of theatres (venues), with their various type statements (in descending order of the number of types)Maintenance tasks: .(Q41253)movie theater statement referring to (P31)instance of do not require another (Q786922)drive-in theater ; thus items of the type (Q41253)movie theater , which is in turn a subclass of (Q1454553)outdoor cinema is a subclass of (Q786922)drive-in theater statements that refer to a superclass of any of the other types. Example: (P31)instance of Remove any statements that refer to an organization. Create a separate item for the organization (sometimes you may want to proceed the other way round, creating a new item for the theatre building; you may also inspect the list of reverse statements to see to which type incoming statements predominantly refer to).(P31)instance of Remove any

Use at

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 bd: <http://www.bigdata.com/rdf#>
SELECT   ?item 
         ?itemLabel
         ?countryLabel
         (replace(group_concat(distinct ?type;separator="; "), "http://www.wikidata.org/entity/", "") as ?types)  #Strip the path in order to get only the Q-number.
         (group_concat(distinct ?typeLabel_en;separator="; ") as ?typeLabels_en)
WHERE 
{
  ?item wdt:P31/wdt:P279* wd:Q24354.
  ?item wdt:P31 ?type.
  ?item wdt:P17 wd:Q39.
  OPTIONAL { ?item wdt:P31/rdfs:label ?typeLabel_en . FILTER (lang(?typeLabel_en) = "en") }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
group by ?item                          #List all the variables for which the values are not concatenated!
         ?itemLabel
         ?countryLabel
order by desc (COUNT(?type))

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?_anon_42b5416610844a34809f33a099ae9de193436") v2("?item"):::projected v3("?type") v1("?typeLabel_en"):::projected v6("?typeLabels_en") v5("?types") a2((" ")) a3((" ")) a1((" ")) c4(["wd:Q24354"]):::iri c6(["wd:Q39"]):::iri c9(["bd:serviceParam"]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal v2 --"wdt:P31"--> a2 a2 --"wdt:P279"--> c4 v2 --"wdt:P31"--> v3 v2 --"wdt:P17"--> c6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P31".-> a3 a3 --"rdfs:label"--> v1 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end bind3[/"count(?type)"/] v3 --o bind3 bind3 --as--o v4 bind4[/"replace(,'http://www.wikidata.org/entity/','')"/] null --o bind4 bind4 --as--o v5 bind5[/"?typeLabel_en"/] v1 --o bind5 bind5 --as--o v6