query-8fa7938763e4e62818e103a6e9207d5c

rq turtle/ttl

people with the same family name as a US president SELECT DISTINCT ?presidentLabel ?otherPersonLabel WHERE { wd:Q30 p:P6/ps:P6 ?president. ?president wdt:P734 ?familyName. ?otherPerson wdt:P734 ?familyName. FILTER(?otherPerson != ?president). SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# people with the same family name as a US president
SELECT DISTINCT ?presidentLabel ?otherPersonLabel WHERE {
  wd:Q30 p:P6/ps:P6 ?president.
  ?president wdt:P734 ?familyName.
  ?otherPerson wdt:P734 ?familyName.
  FILTER(?otherPerson != ?president).
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?familyName") v1("?otherPerson") v2("?president") a1((" ")) c6(["bd:serviceParam"]):::iri c1(["wd:Q30"]):::iri c8(["en"]):::literal f0[["?otherPerson != ?president"]] f0 --> v1 f0 --> v2 c1 --"p:P6"--> a1 a1 --"p:statement/P6"--> v2 v2 --"p:direct/P734"--> v3 v1 --"p:direct/P734"--> v3 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c6 --"wikibase:language"--> c8 end