query-5b59a2b784bcb094b17cc57c05a867bb

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 DISTINCT ?owner ?ownerProportion ?ownerLabel ?owned ?ownedLabel WHERE {
{
    wd:Q3295867 wdt:P127 ?owner .
    OPTIONAL {
      wd:Q3295867 p:P127 ?statement1 .
      ?statement1 ps:P127 ?owner .         # this ties the optional clause to the first clause - the ?owner value must be the same
      ?statement1 pq:P1107 ?ownerProportion .
    }
  } UNION {
    ?owned wdt:P127 wd:Q217583 .   # finds 55 directly owned companies (plus 2 coca-cola owners...)
#    ?owned wdt:P127+ wd:Q217583 . # finds 155 directly and indirectly owned companies (plus 2 coca-cola owners...)
#    ?owned wdt:P127* wd:Q217583 . # finds 156 directly and indirectly owned companies - in this query, BH is deemed to own BH. (plus 2 coca-cola owners...)
  } 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,[AUTO_LANGUAGE]". } 
} order by ?owned

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v1("?owned"):::projected v2("?owner"):::projected v4("?ownerProportion"):::projected v3("?statement1") c1(["wd:Q3295867"]):::iri c6(["wd:Q217583"]):::iri c8(["bd:serviceParam"]):::iri c10(["en,#91;AUTO_LANGUAGE#93;"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P127"--> c6 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; c1 --"p:direct/P127"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; c1 -."p:P127".-> v3 v3 --"p:statement/P127"--> v2 v3 --"p:qualifier/P1107"--> v4 end end union0r <== or ==> union0l end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c8 --"wikibase:language"--> c10 end