Open main menu

Wikidata:WikiProject Theatre/Queries

Home

 

Properties

 

Todo

 

Queries

 

Drama schools by number of students on WikidataEdit

The following query uses these:

Features: Map (Q24515275)    

 1 #defaultView:Map
 2 # Drama schools by number of students on Wikidata
 3 SELECT ?school ?schoolLabel ?website ?coords ?students ?sourcedStudents (FLOOR(?sourcedStudents/?students*10000)/100 AS ?layer) WHERE {
 4   # Total number of students on Wikidata
 5   {
 6     SELECT ?school (COUNT(?student) AS ?students) WHERE {
 7       ?school wdt:P31/wdt:P279* wd:Q2143781 .
 8 
 9       ?student wdt:P31 wd:Q5 . 
10       ?student wdt:P69 ?school .
11     } GROUP BY ?school ?schoolLabel
12   }
13 
14   # Number of students with URL reference on Wikidata
15   OPTIONAL {
16     SELECT ?school (COUNT(?student) AS ?sourcedStudents) WHERE {
17       ?school wdt:P31/wdt:P279* wd:Q2143781 .
18 
19       ?student wdt:P31 wd:Q5 . 
20       ?student p:P69 ?schoolStatement .
21       ?schoolStatement ps:P69 ?school .
22       ?schoolStatement prov:wasDerivedFrom ?ref .
23       ?ref pr:P854 ?url .
24 
25     } GROUP BY ?school ?schoolLabel ORDER BY DESC(?students)
26   }
27   
28   # Some other useful data
29   OPTIONAL { ?school wdt:P856 ?website . }
30   OPTIONAL { ?school wdt:P625 ?coords . }
31   
32   SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
33 } ORDER BY DESC(?students)