query-314bb2aeee7208730ec9104b0a882e02

rq turtle/ttl

MEPs on Twitter and Mastodon mirrors SELECT ?item ?itemLabel ?handle ?mastodon (GROUP_CONCAT(DISTINCT ?groupLabel; SEPARATOR = "; ") AS ?groups) (GROUP_CONCAT(DISTINCT ?languageLabel; SEPARATOR = "; ") AS ?languages) WHERE { SELECT DISTINCT ?item ?itemLabel ?handle ?mastodon ?groupLabel ?languageLabel WHERE { ?item p:P39 ?officeStatement. ?officeStatement ps:P39 wd:Q27169. OPTIONAL { ?officeStatement pq:P4100 ?group. } OPTIONAL { ?item wdt:P1412 ?language. } ?item p:P27 ?citizenshipStatement. ?citizenshipStatement ps:P27 ?citizenship. MINUS { ?citizenshipStatement pq:P582 ?endtime } . ?item p:P2002 ?handleStatement. ?handleStatement ps:P2002 ?handle. # But not those which ended already MINUS { ?handleStatement pq:P582 ?endtime } . OPTIONAL { ?item p:P4033 ?mastodonStatement. ?mastodonStatement ps:P4033 ?mastodon. ?mastodonStatement pq:P3831 wd:Q654822. ?mastodonStatement wikibase:rank ?rank }. SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". } } LIMIT 2000 } GROUP BY ?item ?itemLabel ?handle ?mastodon

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#>
# MEPs on Twitter and Mastodon mirrors
SELECT ?item ?itemLabel ?handle ?mastodon (GROUP_CONCAT(DISTINCT ?groupLabel; SEPARATOR = "; ") AS ?groups) (GROUP_CONCAT(DISTINCT ?languageLabel; SEPARATOR = "; ") AS ?languages) WHERE {
  SELECT DISTINCT ?item ?itemLabel ?handle ?mastodon ?groupLabel ?languageLabel
WHERE
{
  ?item p:P39 ?officeStatement.
  ?officeStatement ps:P39 wd:Q27169.
  OPTIONAL { ?officeStatement pq:P4100 ?group. }
  OPTIONAL { ?item wdt:P1412 ?language. }
  ?item p:P27 ?citizenshipStatement.
  ?citizenshipStatement ps:P27 ?citizenship.
  MINUS { ?citizenshipStatement pq:P582 ?endtime } .
  ?item p:P2002 ?handleStatement.
  ?handleStatement ps:P2002 ?handle.
  # But not those which ended already
  MINUS { ?handleStatement pq:P582 ?endtime } .
  OPTIONAL { ?item p:P4033 ?mastodonStatement.
           ?mastodonStatement ps:P4033 ?mastodon.
           ?mastodonStatement pq:P3831 wd:Q654822.
           ?mastodonStatement wikibase:rank ?rank }.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
LIMIT 2000
}
GROUP BY ?item ?itemLabel ?handle ?mastodon

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?citizenship") v5("?citizenshipStatement") v7("?endtime") v3("?group") v13("?groupLabel"):::projected v15("?groups") v9("?handle"):::projected v8("?handleStatement") v1("?item"):::projected v4("?language") v14("?languageLabel"):::projected v16("?languages") v11("?mastodon"):::projected v10("?mastodonStatement") v2("?officeStatement") v12("?rank") c3(["wd:Q27169"]):::iri c17(["bd:serviceParam"]):::iri c14(["wd:Q654822"]):::iri c19(["#91;AUTO_LANGUAGE#93;,en"]):::literal v1 --"p:P39"--> v2 v2 --"p:statement/P39"--> c3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:qualifier/P4100".-> v3 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:direct/P1412".-> v4 end v1 --"p:P27"--> v5 v5 --"p:statement/P27"--> v6 subgraph minus0["MINUS"] style minus0 stroke-width:6px,fill:pink,stroke:red; v5 --"p:qualifier/P582"--> v7 end v1 --"p:P2002"--> v8 v8 --"p:statement/P2002"--> v9 subgraph minus1["MINUS"] style minus1 stroke-width:6px,fill:pink,stroke:red; v8 --"p:qualifier/P582"--> v7 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v1 -."p:P4033".-> v10 v10 --"p:statement/P4033"--> v11 v10 --"p:qualifier/P3831"--> c14 v10 --"wikibase:rank"--> v12 end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c17 --"wikibase:language"--> c19 end bind4[/"?groupLabel"/] v13 --o bind4 bind4 --as--o v15 bind5[/"?languageLabel"/] v14 --o bind5 bind5 --as--o v16