Skip to content

Instantly share code, notes, and snippets.

@pwin
Last active December 31, 2015 00:49
Show Gist options
  • Save pwin/7909916 to your computer and use it in GitHub Desktop.
Save pwin/7909916 to your computer and use it in GitHub Desktop.
SPARQL query to get the total utility consumption per month for a building
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#>
select ?month (sum(?o) as ?val )
where {
?slice gol:refBuilding buildingCode:AB0001 ;
gol:reportDateTime ?dt ;
qb:sliceStructure gol:sliceByDay;
qb:observation ?obs .
?obs gol:utilityConsumption ?o ;
gol:refUtility util:electricity .
filter (xsd:dateTime(?dt) >= '2013-06-11T00:00:00Z'^^xsd:dateTime &&
xsd:dateTime(?dt) < '2013-12-11T00:00:00Z'^^xsd:dateTime)
}
group by (month(?dt) as ?month)
order by ?month
limit 2000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment