query-dcb730105e1b83e761279ce2131a728e

rq turtle/ttl

Wikimedia Commons SPARQL service federation. The query went like this: (P18)image that you understand Wikimedia Commons + Wikidata federation (at least better than I do). I was trying to do some federated query but failed. The goal was to find uploaders of pictures linked to Czech municipalities via Wikidata:Request_a_query/Archive/2020/10#Querry_for_Wikimedia_CommonsHi, I noticed at

Use at

PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?username (count(distinct ?image) as ?count) WITH
{
  SELECT ?item ?image
  WHERE
  {
    SERVICE <https://query.wikidata.org/sparql>
    {
      ?item wdt:P31 wd:Q5153359 .
      ?item wdt:P18 ?image .
    }
  }
} AS %get_items
WHERE
{
  INCLUDE %get_items
  //somehow link ?image to its structured file ... reverse of schema:contentUrl ... sort of like ?image HASFILE ?file .  
  ?file p:P170/pq:P4174 ?username . 

} group by ?username

Query found at