query-fb63fd21b54e35760a8e2057bc8f1912

rq turtle/ttl

21:11, 1 March 2021 (UTC)) talk (Elya--(please ping me for an answer)Thanks! 300 LIMIT ?coords ?itemLabel ?item GROUP BY } } . ?architectLabel label:rdfs ?architect . ?itemLabel label:rdfs ?item ."[AUTO_LANGUAGE],de" language:wikibase serviceParam:bd { label:wikibase SERVICE } # up to 7 per ?item, needs grouping .?architect P84:wdt ?item { OPTIONAL } # might be more than one. I want the first one .?img P18:wdt ?item {OPTIONAL } .?coords P625:wdt ?item {OPTIONAL ].?date P585:pq ;?award P166:ps[ P166:p ;Q1795794:wd P166:wdt ?item { WHERE )?architects AS )", "=separator;?architectLabel DISTINCT(GROUP_CONCAT( )?year as ))?date(YEAR(MIN( )?image as )?img(SAMPLE( ?coords ?itemLabel ?item SELECT #defaultView:Map 21:26, 1 March 2021 (UTC) Jura: I tried to fix it above. "Query is malformed: Bad aggregate" means that in SELECT you have unaggregated variables that are missing in "GROUP BY". Somewhere further down, it lists one ( "Non-aggregate variable in select expression: coords"). It's an error message I get frequently ;) I also changed the year and the image output to list just one. --- Elya@22:21, 1 March 2021 (UTC)) talk (Dipsacus fullonum. There is no order of statements in Wikidata, so no image can be called "the first". You just get a image. --?item wdt:P18 ?img. # might be more than one. I want the first one: Another thing: The query has the comment Elya@ 22:13, 1 March 2021 (UTC)) talk (Dipsacus fullonum is received and not some other award. --(Q1795794)Kölner Architekturpreis so the point of time is when ?item p:P166 [ps:P166 wd:Q1795794; a wikibase:BestRank; pq:P585 ?date]. and that received some unspecified award on some point of time. It can both be the same award and two different awards. You probably mean (Q1795794)Kölner Architekturpreis : Your query select items that received Elya@ 21:52, 1 March 2021 (UTC)) talk (Elya, aaaah, yes, I see. Thanks! I'll see what else I can do with my little dataset ;-) And I promise I'll read the error message stacks next time … --Jura

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
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#>
# Where did they study? 

#defaultView:Map
#defaultView:Map
SELECT 
  ?item ?itemLabel 
  ?coords 
  (SAMPLE(?img) as ?image) 
  (MIN(YEAR(?date)) as ?year) 
  (GROUP_CONCAT(DISTINCT ?architectLabel;separator=", ") AS ?architects)
  (GROUP_CONCAT(DISTINCT ?buildingLabel;separator=", ") AS ?buildings)
WHERE 
{
  ?building p:P166 [ps:P166 wd:Q1795794; a wikibase:BestRank; pq:P585 ?date ].  
  OPTIONAL{ ?building wdt:P18 ?img }
  ?building wdt:P84 ?architect.
  OPTIONAL{ ?architect wdt:P69 ?item . 
  OPTIONAL{ ?item wdt:P625 ?coords } }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de".
                        ?item rdfs:label ?itemLabel .
                        ?architect rdfs:label ?architectLabel .
                        ?building rdfs:label ?buildingLabel .
                          }
} 
GROUP BY ?item ?itemLabel ?coords

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v4("?architect") v8("?architectLabel"):::projected v12("?architects") v2("?building") v9("?buildingLabel"):::projected v13("?buildings") v6("?coords"):::projected v1("?date"):::projected v10("?image") v3("?img"):::projected v5("?item"):::projected v7("?itemLabel"):::projected v11("?year") a1((" ")) c14(["#91;AUTO_LANGUAGE#93;,de"]):::literal c4(["wikibase:BestRank"]):::iri c12(["bd:serviceParam"]):::iri c2(["wd:Q1795794"]):::iri a1 --"p:statement/P166"--> c2 a1 --"a"--> c4 a1 --"p:qualifier/P585"--> v1 v2 --"p:P166"--> a1 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."p:direct/P18".-> v3 end v2 --"p:direct/P84"--> v4 subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v4 -."p:direct/P69".-> v5 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v5 -."p:direct/P625".-> v6 end end subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c12 --"wikibase:language"--> c14 v5 --"rdfs:label"--> v7 v4 --"rdfs:label"--> v8 v2 --"rdfs:label"--> v9 end bind4[/"sample(?img)"/] v3 --o bind4 bind4 --as--o v10 bind5[/"min(year-from-dateTime(?date))"/] v1 --o bind5 bind5 --as--o v11 bind6[/"?architectLabel"/] v8 --o bind6 bind6 --as--o v12 bind7[/"?buildingLabel"/] v9 --o bind7 bind7 --as--o v13