query-e76de59d10c4f4820ff181690a5ba049

rq turtle/ttl

TODO

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 pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?pen1 ?pen2 ?issue
WHERE 
{
  ?item wdt:P31 wd:Q161705.
  ?item p:P879 ?stat1.
  ?item p:P879 ?stat2.
  filter(str(?stat1) > str(?stat2))

  { ?stat1 ps:P879 ?pen1. 
    ?stat2 ps:P879 ?pen2.
    filter   (?pen1 != ?pen2)
    BIND("different pennants" as ?issue) 
  }
  UNION
  { ?stat1 ps:P879 ?pen1. 
    ?stat2 ps:P879 ?pen2.
    filter   (?pen1 = ?pen2)
    OPTIONAL {?stat1 pq:P137 ?op1.}
    OPTIONAL {?stat2 pq:P137 ?op2.}
    filter(!BOUND(?op1) || !BOUND(?op1))
    BIND("missing operator" as ?issue) 
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } 

}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?issue"):::projected v3("?item"):::projected v7("?op1") v8("?op2") v4("?pen1"):::projected v5("?pen2"):::projected v1("?stat1") v2("?stat2") c7(["bd:serviceParam"]):::iri c2(["wd:Q161705"]):::iri c9(["#91;AUTO_LANGUAGE#93;,en"]):::literal f0[["str(?stat1) > str(?stat2)"]] f0 --> v1 f0 --> v2 v3 --"p:direct/P31"--> c2 v3 --"p:P879"--> v1 v3 --"p:P879"--> v2 subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; f1[["(not bound(?op1) || not bound(?op1))"]] f1 --> v7 f2[["?pen1 = ?pen2"]] f2 --> v4 f2 --> v5 v1 --"p:statement/P879"--> v4 v2 --"p:statement/P879"--> v5 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:qualifier/P137".-> v7 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:qualifier/P137".-> v8 end bind3[/"'missing operator'"/] bind3 --as--o v9 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; f4[["?pen1 != ?pen2"]] f4 --> v4 f4 --> v5 v1 --"p:statement/P879"--> v4 v2 --"p:statement/P879"--> v5 bind5[/"'different pennants'"/] bind5 --as--o v9 end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c7 --"wikibase:language"--> c9 end