User:Srittau/SPARQL-Queries

WikidataEdit

All items that use a certain property as qualifierEdit

SELECT ?s ?p ?o WHERE {
  ?stmt pq:P1856 ?o .
  ?s ?p ?stmt.
} LIMIT 100
Try it!

All (item, property) pairs that use stated in (P248) referencing the property valueEdit

PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX r: <http://www.wikidata.org/prop/reference/>SELECT ?s ?p WHERE {
  ?srcStmt r:P248 ?src .               # all source statements
  ?stmt prov:wasDerivedFrom ?srcStmt . # all statements using source statements
  ?stmt ?stmtProp ?src .               # statements where the object references the source
  ?s ?p ?stmt .                        # subjects/predicates of these statements
} LIMIT 100
Try it!

WikipediaEdit

All Wikipdia language versionsEdit

SELECT ?wpLabel ?lLabel ?iso6391Label ?iso6392Label ?iso6393Label WHERE {
    ?wp wdt:P31 wd:Q10876391 .
    ?wp wdt:P407 ?l .
    ?l wdt:P218 ?iso6391 .
    ?l wdt:P219 ?iso6392 .
    ?l wdt:P220 ?iso6393 .
    
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "en" .
    }
 }
Try it!

GermanyEdit

All places in GermanyEdit

SELECT DISTINCT ?location ?subdivisionLabel ?locationLabel WHERE {
    ?subdivision wdt:P279+ wd:Q387917 .
    ?location wdt:P31 ?subdivision .
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "de" .
    }
 }
Try it!

Places in Berlin with located in the administrative territorial entity (P131) not pointing to a Ortsteil (Q253019)Edit

SELECT ?s ?sLabel ?veLabel ?vetLabel WHERE {
	?s wdt:P131+ wd:Q64 .  # everything located in Berlin (or a subdivision)
	?s wdt:P131 ?ve .      # the subdivisions this is located in
    ?ve wdt:P131+ wd:Q64 . # filter out all non-Berlin subdivisions (for subjects in multiple states)
    ?ve wdt:P31 ?vet .     # type of the subdivision
    # filter everything located in an Ortsteil or Ortslage
    FILTER (?vet != wd:Q253019 && ?vet != wd:Q1669338) .
    # filter Orteile
    ?s wdt:P31 ?st .
    FILTER (?st != wd:Q253019) .
    SERVICE wikibase:label {
      bd:serviceParam wikibase:language "de" .
    }
} ORDER BY ?veLabel ?sLabel LIMIT 100
Try it!

AviationEdit

All German aerodromes (via located in the administrative territorial entity (P131))Edit

[1]

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
PREFIX q: <http://www.wikidata.org/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?airport ?icao ?airportLabel WHERE {
    ?subdivision wdt:P279+ wd:Q387917 .   # all subdivision types of Germany
    ?location wdt:P31 ?subdivision .      # all locations in Germany
    ?airportType wdt:P279* wd:Q62447 .    # all types of aerodromes
    ?airport wdt:P31 ?airportType .       # all aerodromes
    ?airport wdt:P131 ?location .         # all aerodromes in Germany
    OPTIONAL { ?airport wdt:P239 ?icao }
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "de" .
    }
 } ORDER BY ?airportLabel

All German aerodromes (via country (P17))Edit

[2]

PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX v: <http://www.wikidata.org/prop/statement/>
PREFIX q: <http://www.wikidata.org/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?airport ?icao ?airportLabel WHERE {
    ?airportType wdt:P279* wd:Q62447 .
    ?airport wdt:P31 ?airportType .
    ?airport wdt:P17 wd:Q183 .
    OPTIONAL { ?airport wdt:P239 ?icao }
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "de" .
    }
 } ORDER BY ?airportLabel