query-fb63fd21b54e35760a8e2057bc8f1912
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
- https://query.wikidata.org/sparql
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