User:Jneubert/SWIB queries

From Wikidata
Jump to navigation Jump to search

SWIB20 institution map[edit]

Federated query, using a custom set of instition items with the number of SWIB20 participants from these institutions.

The following query uses these:

Features: map (Q24515275)  View with Reasonator View with SQID

#defaultView:Map
#
# SWIB20 participants' institutions, mapped to Wikidata and enriched from there
#
PREFIX zbwext: <http://zbw.eu/namespaces/zbw-extensions/>
#
# from possibly multi-valued fields, use an arbitrary value
select distinct ?item ?itemLabel (sample(?logo1) as ?logo) (sample(?img) as ?image) (sample(?pos) as ?coord) ?participants
where {
  # institutions' items and count of participants from custom WDQS-enabled endpoint
  service <http://zbw.eu/beta/sparql/econ_corp/query> {
    ?item zbwext:swib20participants ?count .
    bind(concat(str(?count), ' participant', if(?count > 1, 's', '')) as ?participants)
  }
  optional { ?item wdt:P18 ?img . }
  optional { ?item wdt:P154 ?logo1 . }
  optional { ?item wdt:P625 ?pos1 . }
  optional { ?item wdt:P159/wdt:P625 ?pos2 . }
  optional { ?item wdt:P131/wdt:P625 ?pos3 . }
  optional { ?item wdt:P17/wdt:P625 ?pos4 . }
  # use the most precise position
  bind(coalesce(?pos1, ?pos2, ?pos3, ?pos4) as ?pos)
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,[AUTO_LANGUAGE],de,fr,es". }
}
group by ?item ?itemLabel ?participants

Static version of the query - all information explicitly put into a "values" clause, does not need a custom SPARQL endpoint

Institutions with most participants at SWIB20[edit]

Federated query, using a custom set of instition items with the number of SWIB20 participants from these institutions.

# SWIB20 participants aggregated by institution
#
PREFIX zbwext: <http://zbw.eu/namespaces/zbw-extensions/>
#
select ?item ?itemLabel ?count
where {
  # institutions' items and count of participants from custom WDQS-enabled endpoint
  service <http://zbw.eu/beta/sparql/econ_corp/query> {
    ?item zbwext:swib20participants ?count.
    bind(concat(str(?count), ' participant', if(?count > 1, 's', '')) as ?participants)
  }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en,[AUTO_LANGUAGE],de,fr,es". }
}
order by desc(?count)
Try it!