query-7d7bcfae0a0e0c2b17fc28f08b388e5b

rq turtle/ttl

List metadata select distinct ?item ?list ?listLabel ?is_a_list_of ?is_a_list_ofLabel ?is_a_list_of_PQ_position_held ?is_a_list_of_PQ_position_heldLabel ?category ?categoryLabel where { { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } . # ambassador or high commissioner ?item wdt:P2354 ?list . optional { ?list p:P360 ?statement. ?statement ps:P360 ?is_a_list_of. optional {?statement pq:P39 ?is_a_list_of_PQ_position_held} optional {?list wdt:P1754 ?category . } }
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_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 pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
# List metadata
select distinct ?item ?list ?listLabel ?is_a_list_of ?is_a_list_ofLabel ?is_a_list_of_PQ_position_held ?is_a_list_of_PQ_position_heldLabel ?category ?categoryLabel where
{
  { ?item wdt:P31 wd:Q18115939 . } union { ?item wdt:P31 wd:Q56760832 } . # ambassador or high commissioner
  ?item wdt:P2354 ?list  .
  optional 
  {
    ?list p:P360 ?statement.
    ?statement ps:P360 ?is_a_list_of.
    optional {?statement pq:P39 ?is_a_list_of_PQ_position_held}
    optional {?list wdt:P1754 ?category . }
  }  
  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; v6("?category"):::projected v4("?is_a_list_of"):::projected v5("?is_a_list_of_PQ_position_held"):::projected v1("?item"):::projected v2("?list"):::projected v3("?statement") c2(["wd:Q18115939"]):::iri c10(["bd:serviceParam"]):::iri c3(["wd:Q56760832"]):::iri c12(["#91;AUTO_LANGUAGE#93;,en"]):::literal subgraph union0[" Union "] subgraph union0l[" "] style union0l fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P31"--> c3 end subgraph union0r[" "] style union0r fill:#abf,stroke-dasharray: 3 3; v1 --"p:direct/P31"--> c2 end union0r <== or ==> union0l end v1 --"p:direct/P2354"--> v2 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:P360".-> v3 v3 --"p:statement/P360"--> v4 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:qualifier/P39".-> v5 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P1754".-> v6 end end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c10 --"wikibase:language"--> c12 end