People

From MtM

Back to the overview of all query topics: back

Images of the listed persons

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX mmd: <https://mtm.uni-trier.de/entity/> 
PREFIX mmdt: <https://mtm.uni-trier.de/prop/direct/>
#defaultView:ImageGrid
SELECT ?personLabel ?image WHERE {
    ?person mmdt:P3 mmd:Q241.                 # Person is a real person
    ?person mmdt:P2 ?wikidataEntity.          # Person has an exact match with a Wikidata item
  
    SERVICE <https://query.wikidata.org/sparql> {
      ?wikidataEntity wdt:P18 ?image.         # Wikidata item has an image via P18
    }
  
    SERVICE wikibase:label {                          
      bd:serviceParam wikibase:language "en". # Adds readable labels
    }
}

Click here: Test SPARQL query

Map of birthplaces of all real persons in this Wikibase instance

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX mmd: <https://mtm.uni-trier.de/entity/> 
PREFIX mmdt: <https://mtm.uni-trier.de/prop/direct/>
#defaultView:Map
SELECT ?personLabel ?birthplaceLabel ?coordinates WHERE {
    ?person mmdt:P3 mmd:Q241.                 # Person is a real person
    ?person mmdt:P2 ?wikidataEntity.          # Person has an exact match with a Wikidata item
  
    SERVICE <https://query.wikidata.org/sparql> {
      ?wikidataEntity wdt:P19 ?birthplace.    # Wikidata item has a birthplace via P19
      ?birthplace wdt:P625 ?coordinates.      # P625 = coordinates in Wikidata
    }
  
    SERVICE wikibase:label {                          
      bd:serviceParam wikibase:language "en". # Adds readable labels
    }
}

Click here: Test SPARQL query

List of all persons with gender and function within the production

PREFIX wdt: <https://mtm.uni-trier.de/prop/direct/>
PREFIX wd: <https://mtm.uni-trier.de/entity/>

SELECT ?productionLabel ?personLabel ?firstNameLabel ?lastNameLabel ?genderLabel ?propLabel WHERE {
  ?person wdt:P3 wd:Q241.                    # Person is a real person
  OPTIONAL {                                 # If this information is missing in a person item
    ?person wdt:P17 ?gender.                 # Person has gender
    ?person wdt:P27 ?firstName.              # Person has first name
    ?person wdt:P28 ?lastName.               # Person has last name
  }
  ?production ?function ?person.             # Production is linked to the person via a function
  ?production wdt:P3 wd:Q309.                # Production is a production
  ?prop wikibase:directClaim ?function.      # Adds readable property labels
  
  SERVICE wikibase:label {                          
    bd:serviceParam wikibase:language "en". # Adds readable labels
  }
}

ORDER BY ?production

Click here: Test SPARQL query

Is there a director who oversaw multiple productions? If yes, which ones?

PREFIX wdt: <https://mtm.uni-trier.de/prop/direct/>
PREFIX wd: <https://mtm.uni-trier.de/entity/>

SELECT ?regie ?regieLabel ?inszenierung ?inszenierungLabel WHERE {
  
  {
    SELECT ?regie (COUNT(?inszenierung) AS ?anzahlInszenierungen) WHERE { #Query for number of productions
      ?inszenierung wdt:P15 ?regie. #Production has director
    }
    GROUP BY ?regie ?regieLabel       #Group by directors and their labels
    HAVING (COUNT(?inszenierung) > 1) #If more than one production exists
  }
  
  ?inszenierung wdt:P15 ?regie.     #Main query, to include the director’s productions in the result

  SERVICE wikibase:label {
    bd:serviceParam wikibase:language "en".
  }
}
ORDER BY ?regieLabel ?inszenierungLabel

Click here: Test SPARQL query

Is there an actor who participated in multiple productions? If yes, which ones?

PREFIX wdt: <https://mtm.uni-trier.de/prop/direct/>
PREFIX wd: <https://mtm.uni-trier.de/entity/>

SELECT ?darstellerIn ?darstellerInLabel ?inszenierung ?inszenierungLabel WHERE {
{
SELECT ?darstellerIn ?darstellerInLabel (COUNT(?inszenierung) AS ?count) WHERE { #Subquery for number of productions
  ?inszenierung wdt:P14 ?darstellerIn.                                           #Production has an actor
}
GROUP BY ?darstellerIn ?darstellerInLabel
HAVING (COUNT(?inszenierung) > 1)
}
?inszenierung wdt:P14 ?darstellerIn.                                              #Main query, to include the actor’s productions in the result

  SERVICE wikibase:label {                                                        #Adds readable labels
    bd:serviceParam wikibase:language "en".
  }
}

ORDER BY ?darstellerInLabel ?inszenierungLabel

Click here: Test SPARQL query