User:Bamyers99

From Wikidata
Jump to: navigation, search
Babel user information
en-N This user has a native understanding of English.
de-0 Dieser Benutzer beherrscht Deutsch nicht (oder versteht es nur mit beträchtlichen Schwierigkeiten).
es-0 Este usuario no tiene ningún conocimiento del español (o lo entiende con mucha dificultad).
fr-0 Cet utilisateur n’a aucune connaissance en français (ou le comprend avec de grandes difficultés).
Users by language

Links[edit]

SPARQL

SPARQL examples[edit]

Rdf mapping-vector.svg

Searches super-classes (non-truthy instance of), checks for non-existence, must have enwiki link[edit]

Bridges in USA w/o crosses.

SELECT DISTINCT ?s ?sLabel WHERE {
  ?s wdt:P17 wd:Q30 .
  ?s p:P31 ?stmt .
  ?stmt ps:P31/wdt:P279* wd:Q12280 .
  OPTIONAL {
    ?s wdt:P177 ?dummy
  }
  FILTER ( !bound(?dummy) ) .
  FILTER EXISTS {
    ?article schema:about ?s .
    ?article schema:inLanguage "en" .
    ?article schema:isPartOf <https://en.wikipedia.org/>
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
 }

Try it!

Searches super-administrative entities[edit]

Covered bridges in Pennsylvania.

SELECT DISTINCT ?s ?sLabel WHERE {
  ?s wdt:P31 wd:Q1825472 .
  ?s wdt:P131/wdt:P131* wd:Q1400 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
 }
ORDER BY ?sLabel

Try it!

A qualifier's 'value counts' for a specific property[edit]

population (P1082) qualifier determination method (P459).

SELECT ?determinemethod ?determinemethodLabel ?count WHERE {
  {
    SELECT ?determinemethod (COUNT(?determinemethod) AS ?count) WHERE {
      ?s p:P1082 ?popstatement .
      ?popstatement pq:P459 ?determinemethod .
    }
    GROUP BY ?determinemethod
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY DESC(?count)

Try it!

A qualifier's usage counts[edit]

Qualifier start time (P580).

SELECT ?wdP ?wdPLabel ?count WHERE {
  {
    SELECT ?prop (COUNT(?prop) AS ?count) WHERE {
      ?s ?prop ?propstatement .
      ?propstatement pq:P580 ?proptime .
    }
    GROUP BY ?prop
  }
  
  ?wdP wikibase:claim ?prop .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY DESC(?count)

Try it!

A property's qualifier property counts, includes a SPARQL query of instances[edit]

Property formatter URL (P1630).

SELECT ?qual ?qualLabel ?count (IRI(CONCAT("https://query.wikidata.org/#%23%20qualifier%20-%20", ?qualLabel, "%0ASELECT%20%3Fitem%20%3FitemLabel%20%3FqualLabel%0AWHERE%0A{%0A%09%3Fitem%20p%3AP1630%20%3Fstatement%20.%0A%20%20%20%20%3Fstatement%20pq%3A", SUBSTR(STR(?qual),32), "%20%3Fqual%0A%09SERVICE%20wikibase%3Alabel%20{%20bd%3AserviceParam%20wikibase%3Alanguage%20%22en%22%20%20}%20%20%20%20%0A}%0AORDER BY %3FitemLabel")) as ?instances)
WHERE {
  {
    SELECT ?qual (COUNT(DISTINCT ?item) AS ?count) WHERE {
         hint:Query hint:optimizer "None" .
         ?item p:P1630 ?statement .
         ?statement ?pq_qual ?pq_obj .
         ?qual wikibase:qualifier ?pq_qual .
    }  GROUP BY ?qual
  } .

  OPTIONAL {
    ?qual rdfs:label ?qualLabel filter (lang(?qualLabel) = "en") .
  }
}
ORDER BY DESC(?count) ASC(?qualLabel)

Try it!

Missing a qualifier[edit]

award received (P166)  Nobel Prize in Physiology or Medicine (Q80061) missing point in time (P585).

SELECT DISTINCT ?item ?itemLabel
WHERE {
  ?item p:P166 ?awardStat .
  ?awardStat ps:P166 wd:Q80061 .
  OPTIONAL {
    ?awardStat pq:P585 ?when .
  }
  FILTER ( !bound(?when) ) .
  
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY ?itemLabel

Try it!

Unreferenced statement[edit]

award received (P166)  Nobel Prize in Physiology or Medicine (Q80061) missing reference.

SELECT DISTINCT ?item ?itemLabel
WHERE {
  ?item p:P166 ?stmt .
  ?stmt ps:P166 wd:Q80061 .
  OPTIONAL {
      ?stmt prov:wasDerivedFrom ?derivedFrom .
  }
  FILTER ( !bound(?derivedFrom) ) .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" . }
}
ORDER BY ?itemLabel

Try it!

Reference URL starts with[edit]

SELECT DISTINCT ?item ?itemLabel
WHERE {
  ?item p:P1411 ?stmt .
  ?stmt prov:wasDerivedFrom ?derivedFrom .
  ?derivedFrom pr:P854 ?refurl .
  FILTER(STRSTARTS(xsd:string(?refurl), "http://www.nobelprize.org/"))
  
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY ?itemLabel

Try it!

Multiple optionals, or filter, must have English label[edit]

SELECT DISTINCT ?s ?sLabel ?fatherLabel ?motherLabel WHERE {
  ?s wdt:P31/wdt:P279* wd:Q726 .
  OPTIONAL {
    ?s wdt:P22 ?father
    }
  OPTIONAL {
    ?s wdt:P25 ?mother
    }
  OPTIONAL {
    ?s wdt:P3165 ?dummy
  }
  FILTER ( !bound(?dummy) ) .
  FILTER (bound(?father) || bound(?mother) ) .
  FILTER(EXISTS {
    ?s rdfs:label ?lang_label.
    FILTER(LANG(?lang_label) = "en")
  })
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY ?sLabel

Try it!