query-2b3d1493cd707d3e38c68c5371033be8

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 schema: <http://schema.org/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX commons: <http://commons.wikimedia.org/wiki/Special:FilePath/>
PREFIX sdc: <https://commons.wikimedia.org/entity/>

SELECT ?item ?itemLabel ?sdc ?img ?wmuser ?authorurl ?authorname ?licenseLabel
WHERE {
   # We need precise control of ordering 
  SERVICE <https://query.wikidata.org/sparql> {
    SELECT ?item (SAMPLE(?img_) AS ?img)
    WHERE {
      ?item wdt:P106 wd:Q169470.
      ?item wdt:P31 wd:Q5.
      ?item wdt:P1801 ?img_ .
    }
    GROUP BY ?item
  }
  ?sdc schema:url ?img .
  OPTIONAL { ?sdc wdt:P275 ?license . }
  OPTIONAL {
    ?sdc p:P170 ?creator_st .
    ?creator_st a wikibase:BestRank .
    OPTIONAL { ?creator_st pq:P4174 ?wmuser . }
    OPTIONAL { ?creator_st pq:P2699 ?authorurl . }
    OPTIONAL { ?creator_st pq:P2093 ?authorname . }
  }
  SERVICE <https://query.wikidata.org/sparql> {
    OPTIONAL { ?license rdfs:label ?licenseLabel. FILTER(LANG(?licenseLabel)="en") }
    OPTIONAL { ?item rdfs:label ?itemLabel. FILTER(LANG(?itemLabel)="en") }
  }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v9("?authorname"):::projected v8("?authorurl"):::projected v6("?creator_st") v3("?img"):::projected v2("?img_") v1("?item"):::projected v10("?itemLabel"):::projected v5("?license") v11("?licenseLabel"):::projected v4("?sdc"):::projected v7("?wmuser"):::projected c3(["wd:Q169470"]):::iri c11(["wikibase:BestRank"]):::iri c5(["wd:Q5"]):::iri subgraph s1["https://query.wikidata.org/sparql"] style s1 stroke-width:4px; v1 --"p:direct/P106"--> c3 v1 --"p:direct/P31"--> c5 v1 --"p:direct/P1801"--> v2 bind1[/"sample(?img_)"/] v2 --o bind1 bind1 --as--o v3 end v4 --"schema:url"--> v3 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P275".-> v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:P170".-> v6 v6 --"a"--> c11 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:qualifier/P4174".-> v7 end subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:qualifier/P2699".-> v8 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v6 -."p:qualifier/P2093".-> v9 end end subgraph s1["https://query.wikidata.org/sparql"] style s1 stroke-width:4px; subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v5 -."rdfs:label".-> v11 end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v1 -."rdfs:label".-> v10 end end