Skip to content

Instantly share code, notes, and snippets.

@thomasdarimont
Created September 3, 2014 15:21
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/4247d16acdc57504e00c to your computer and use it in GitHub Desktop.
Save thomasdarimont/4247d16acdc57504e00c to your computer and use it in GitHub Desktop.
copy(
with
base_data as
(
select
alm.*
, dd.day
, dd.hour
, dd.minute
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
, min(bd.household_id) as household_id
, min(bd.plug_id) as plug_id
from base_data bd
group by
bd.house_id
,bd.day
,bd.hour
,bd.minute
)
to 'D:\\development\\projects\\xd-keynote\\load_test\\agg_load_min_by_h.csv' CSV
@thomasdarimont
Copy link
Author

Query returned successfully: 40120 rows affected, 5989 ms execution time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment