query-2f958a0ca03f4580988bf1aa4eaadd42
Cactaceae taxa with names referenced to be stated in (P248) either of two books
Use at
- https://query.wikidata.org/sparql
 
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 prov: <http://www.w3.org/ns/prov#>
PREFIX pr: <http://www.wikidata.org/prop/reference/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?a ?aLabel ?taxo_1 ?taxo_2 ?bLabel WHERE {
   ?a wdt:P171* wd:Q14560 .   #  Cactaceae
   ?a wdt:P171 ?b .           #  parent taxon
   {
     SELECT DISTINCT ?a WHERE {
        { ?a p:P225/prov:wasDerivedFrom/pr:P248 wd:Q13520496 }
        UNION
        { ?a p:P225/prov:wasDerivedFrom/pr:P248 wd:Q10695694 }
     }
   }
  OPTIONAL {
     ?a p:P225 ?taxo_stmt .
     ?taxo_stmt ps:P225 ?taxo_1 .    # taxonomic name
     ?taxo_stmt prov:wasDerivedFrom ?ref .
     ?ref pr:P248 wd:Q13520496 .   # Das große Kakteen-Lexikon
  }
  OPTIONAL {
     ?a p:P225  ?taxo_stmt2 .
     ?taxo_stmt2 ps:P225 ?taxo_2 .   # taxonomic name
     ?taxo_stmt2 prov:wasDerivedFrom ?ref2 .
     ?ref2 pr:P248 wd:Q10695694 .   # New Cactus Lexicon
  }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY ?aLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
  v2("?a"):::projected 
  v1("?aLabel"):::projected 
  v3("?b")
  v6("?ref")
  v9("?ref2")
  v5("?taxo_1"):::projected 
  v8("?taxo_2"):::projected 
  v4("?taxo_stmt")
  v7("?taxo_stmt2")
  a1((" "))
  a2((" "))
  a3((" "))
  a4((" "))
  c10(["bd:serviceParam"]):::iri 
  c2(["wd:Q14560"]):::iri 
  c6(["wd:Q13520496"]):::iri 
  c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal 
  c7(["wd:Q10695694"]):::iri 
  v2 --"p:direct/P171"-->  c2
  v2 --"p:direct/P171"-->  v3
  subgraph union0[" Union "]
  subgraph union0l[" "]
    style union0l fill:#abf,stroke-dasharray: 3 3;
    v2 --"p:P225"-->  a3
    a3 --"prov:wasDerivedFrom"-->  a4
    a4 --"p:reference/P248"-->  c7
  end
  subgraph union0r[" "]
    style union0r fill:#abf,stroke-dasharray: 3 3;
    v2 --"p:P225"-->  a1
    a1 --"prov:wasDerivedFrom"-->  a2
    a2 --"p:reference/P248"-->  c6
  end
  union0r <== or ==> union0l
  end
  subgraph optional0["(optional)"]
  style optional0 fill:#bbf,stroke-dasharray: 5 5;
    v2 -."p:P225".->  v4
    v4 --"p:statement/P225"-->  v5
    v4 --"prov:wasDerivedFrom"-->  v6
    v6 --"p:reference/P248"-->  c6
  end
  subgraph optional1["(optional)"]
  style optional1 fill:#bbf,stroke-dasharray: 5 5;
    v2 -."p:P225".->  v7
    v7 --"p:statement/P225"-->  v8
    v7 --"prov:wasDerivedFrom"-->  v9
    v9 --"p:reference/P248"-->  c7
  end
  subgraph s1["http://wikiba.se/ontology#label"]
    style s1 stroke-width:4px;
    c10 --"wikibase:language"-->  c12
  end