Skip to content

Instantly share code, notes, and snippets.

@ckhampus
Last active November 8, 2016 15:06
Show Gist options
  • Save ckhampus/8ba9e22b833a1a76329b6b52b29ad1c9 to your computer and use it in GitHub Desktop.
Save ckhampus/8ba9e22b833a1a76329b6b52b29ad1c9 to your computer and use it in GitHub Desktop.
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?game ?gameLabel (MIN(?date) as ?minDate) ?platformLabel ?steamId WHERE {
?game wdt:P31 wd:Q7889.
?game p:P577 ?dateStm.
?game wdt:P577 ?date.
OPTIONAL { ?dateStm pq:P400 ?platform1. }
#OPTIONAL { ?dateStm pq:P291 ?place. }
OPTIONAL { ?game wdt:P400 ?platform2. }
OPTIONAL { ?game wdt:P1733 ?steamId. }
BIND (COALESCE(?platform1, ?platform2) AS ?platform)
FILTER (
?platform = wd:Q5014725 ||
?platform = wd:Q13361286 ||
?platform = wd:Q10683 ||
?platform = wd:Q48263 ||
?platform = wd:Q1406
)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
GROUP BY ?game ?gameLabel ?platformLabel ?steamId
HAVING((?minDate > "2010-01-01T00:00:00Z"^^xsd:dateTime) && (?minDate < "2020-01-01T00:00:00Z"^^xsd:dateTime))
ORDER BY ?gameLabel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment