Created
December 14, 2013 00:06
-
-
Save pwin/7953867 to your computer and use it in GitHub Desktop.
SPARQL query to get utility consumption for each building by year, month and day
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prefix xsd: <http://www.w3.org/2001/XMLSchema#> | |
prefix gol: <http://cofog01.data.scotland.gov.uk/def/golspie/> | |
prefix qb: <http://purl.org/linked-data/cube#> | |
prefix buildingCode: <http://cofog01.data.scotland.gov.uk/id/facility/> | |
prefix fn: <http://www.w3.org/2005/xpath-functions#> | |
prefix util: <http://cofog01.data.scotland.gov.uk/def/golspie/> | |
prefix skos: <http://www.w3.org/2004/02/skos/core#> | |
PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> | |
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> | |
select ?n ?year ?month ?day (sum(?o) as ?val ) | |
where { | |
?slice gol:refBuilding ?b ; | |
gol:reportDateTime ?dt ; | |
qb:sliceStructure gol:sliceByDay; | |
qb:observation ?obs . | |
?b rdfs:label ?n . | |
?obs gol:utilityConsumption ?o ; | |
gol:refUtility util:electricity . | |
filter (xsd:dateTime(?dt) >= '2013-06-11T00:00:00Z'^^xsd:dateTime && | |
xsd:dateTime(?dt) < afn:now()) | |
} | |
group by ?n (year(?dt) as ?year) (month(?dt) as ?month) (day(?dt) as ?day) ?obs | |
order by ?n ?year ?month ?day ?obs | |
limit 20000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment