query-bbe9eabf7e58482e82aae685bc5e49d8
TODO
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 ?gameGenreLabel ; separator = ", ") AS ?gameGenreLabels)
(GROUP_CONCAT(DISTINCT ?genreLabel ; separator = ", ") AS ?genreLabels)
WHERE {
VALUES ?genres { wd:Q744038 wd:Q1529437 wd:Q1422746 wd:Q1143132 } .
?game wdt:P136 ?genres .
?game wdt:P31 wd:Q7889 .
?game rdfs:label ?gameENLabel .
FILTER( LANG( ?gameENLabel ) = "en" ) .
OPTIONAL {
?game wdt:P577 ?date .
BIND( YEAR( ?date ) AS ?dateYear ) .
} .
OPTIONAL {
?game wdt:P136 ?gameGenre .
?gameGenre wdt:P31 wd:Q659563 .
FILTER( ?gameGenre != wd:Q744038 ) .
?gameGenre rdfs:label ?gameGenreString .
FILTER( LANG( ?gameGenreString ) = "en" ) .
BIND( STR( ?gameGenreString ) AS ?gameGenreLabel ) .
} .
OPTIONAL {
?game wdt:P136 ?genre .
MINUS { ?genre wdt:P31 wd:Q659563 } .
?genre rdfs:label ?genreString .
FILTER( LANG( ?genreString ) = "en" ) .
BIND( STR( ?genreString ) AS ?genreLabel ) .
} .
SERVICE wikibase:label { bd:serviceParam wikibase:language "en" } .
}
GROUP BY ?game
ORDER BY ?dateYears ?gameENLabels
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v9("?date")
v10("?dateYear"):::projected
v14("?dateYears")
v8("?game")
v6("?gameENLabel"):::projected
v14("?gameENLabels")
v4("?gameGenre")
v11("?gameGenreLabel"):::projected
v14("?gameGenreLabels")
v5("?gameGenreString")
v12("?genre")
v13("?genreLabel"):::projected
v15("?genreLabels")
v3("?genreString")
v7("?genres")
c10(["bd:serviceParam"]):::iri
c1(["en"]):::literal
c5(["wd:Q7889"]):::iri
c8(["wd:Q659563"]):::iri
f0[["?gameENLabel = 'en'"]]
f0 --> v6
bind1[/VALUES ?genres/]
bind1-->v7
bind10(["wd:Q744038"])
bind10 --> bind1
bind11(["wd:Q1529437"])
bind11 --> bind1
bind12(["wd:Q1422746"])
bind12 --> bind1
bind13(["wd:Q1143132"])
bind13 --> bind1
v8 --"wdt:P136"--> v7
v8 --"wdt:P31"--> c5
v8 --"rdfs:label"--> v6
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v8 -."wdt:P577".-> v9
bind2[/"year-from-dateTime(?date)"/]
v9 --o bind2
bind2 --as--o v10
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v8 -."wdt:P136".-> v4
v4 --"wdt:P31"--> c8
v4 --"rdfs:label"--> v5
bind3[/"str(?gameGenreString)"/]
v5 --o bind3
bind3 --as--o v11
end
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v8 -."wdt:P136".-> v12
subgraph minus4["MINUS"]
style minus4 stroke-width:6px,fill:pink,stroke:red;
v12 --"wdt:P31"--> c8
end
v12 --"rdfs:label"--> v3
bind5[/"str(?genreString)"/]
v3 --o bind5
bind5 --as--o v13
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c10 --"wikibase:language"--> c1
end
bind10[/"?dateYear"/]
v10 --o bind10
bind10 --as--o v14
bind11[/"?gameENLabel"/]
v6 --o bind11
bind11 --as--o v14
bind12[/"?gameGenreLabel"/]
v11 --o bind12
bind12 --as--o v14
bind13[/"?genreLabel"/]
v13 --o bind13
bind13 --as--o v15