Skip to content

Instantly share code, notes, and snippets.

@thomasdarimont
Created September 3, 2014 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasdarimont/bfd110dd3025adfa818b to your computer and use it in GitHub Desktop.
Save thomasdarimont/bfd110dd3025adfa818b to your computer and use it in GitHub Desktop.
with
base_data as
(
select
alm.*
, dd.day
, dd.hour
, dd.minute
, dd.hourminute
from
agg_load_min_by_h_hh_p alm
inner join
dim_date dd
on
alm.ts = dd.ts
)
select
row_number() over() as id
, min(bd.ts) as ts
, sum(bd.value) as value --sum of avg(...)
, max(bd.property) as property
, bd.house_id
, bd.household_id
, bd.plug_id
from base_data bd
group by
bd.house_id
,bd.household_id
,bd.plug_id
,bd.day
,bd.hour
,bd.hourminute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment