query-d4f9799696de4c78614f9f42ee53f5cb
Sort ordering within a groupI have this script:
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 bd: <http://www.bigdata.com/rdf#>
SELECT
(group_concat(distinct ?dateYear ; separator = ", ") AS ?dateYears)
(group_concat(distinct ?gameENLabel ; separator = ", ") AS ?gameENLabels)
(group_concat(distinct ?typeOfStatementNode ; separator = ", ") AS ?typeOfStatementNodes)
WHERE {
VALUES ?game {
wd:Q4850488
wd:Q4931588
wd:Q5315330
}
?game rdfs:label ?gameENLabel.
FILTER(LANG(?gameENLabel) = "en").
OPTIONAL {
?game wdt:P577 ?date.
BIND(YEAR(?date) AS ?dateYear).
}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en".
}
}
GROUP BY $game
order by desc(?dateYears)
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?date")
v5("?dateYear"):::projected
v7("?dateYears")
v3("?game")
v2("?gameENLabel"):::projected
v7("?gameENLabels")
v6("?typeOfStatementNode"):::projected
v8("?typeOfStatementNodes")
c5(["bd:serviceParam"]):::iri
c1(["en"]):::literal
f0[["?gameENLabel = 'en'"]]
f0 --> v2
bind1[/VALUES ?game/]
bind1-->v3
bind10(["wd:Q4850488"])
bind10 --> bind1
bind11(["wd:Q4931588"])
bind11 --> bind1
bind12(["wd:Q5315330"])
bind12 --> bind1
v3 --"rdfs:label"--> v2
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."wdt:P577".-> v4
bind2[/"year-from-dateTime(?date)"/]
v4 --o bind2
bind2 --as--o v5
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c5 --"wikibase:language"--> c1
end
bind6[/"?dateYear"/]
v5 --o bind6
bind6 --as--o v7
bind7[/"?gameENLabel"/]
v2 --o bind7
bind7 --as--o v7
bind8[/"?typeOfStatementNode"/]
v6 --o bind8
bind8 --as--o v8