Skip to content

Instantly share code, notes, and snippets.

@pwin
Last active December 31, 2015 07:09
Show Gist options
  • Select an option

  • Save pwin/7952532 to your computer and use it in GitHub Desktop.

Select an option

Save pwin/7952532 to your computer and use it in GitHub Desktop.
Utility Value by year, month and date ordered. Uses AFN functions
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#>
select ?year ?month ?day (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) >= '2011-06-11T00:00:00Z'^^xsd:dateTime &&
xsd:dateTime(?dt) < afn:now())
}
group by (year(?dt) as ?year) (month(?dt) as ?month) (day(?dt) as ?day) ?obs
order by ?year ?month ?day ?obs
limit 20000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment