query-50f11d887a9aa997705e425d997b37dd
is also a concern, if it is meant to be a way of getting only a single language WP article ... I'm not sure what languages Commons &c come in, but just in case I've added some rubric which constrains the results to wikipedia articles and ignores Commons, Source &c. So I think perhaps this may give you much of what you want, but not be in quite the form you need yet ... more stuff in the select than you want, the question of whether a ?sitelink is mandatory or optional, aggregation...schema:inLanguage ?thecode: Here they are combined, but it's not clear how you want to filter or aggregate the ?sitelinks &c. If you are supplying a value for ?thecode, then presumably you aim to get one value per row and hence avoid the need for aggregation. Right now the code below will show one row per item/sitelink. Susannaanas@I get the impression that the structure should be like
Use at
- https://query.wikidata.org/sparql
SELECT ?item ?qid ... ?thecode ?thearticle WHERE {
...outer query conditions ...
{ SELECT ?item ?thecode ?thearticle WHERE {
...inner query conditions...
# how to get ?item, a new subquery?
}
ORDER BY DESC (?badge)
LIMIT 1 #choosing one of the existing articles...
}
}
GROUP BY ?item ?qid
ORDER BY DESC (?image)