Skip to content

Instantly share code, notes, and snippets.

@xtender
Created March 18, 2014 21:09
Show Gist options
  • Save xtender/9629696 to your computer and use it in GitHub Desktop.
Save xtender/9629696 to your computer and use it in GitHub Desktop.
Running totals
SQL> exec for r in (select * from table(xf_to_drop)) loop null; end loop;
Elapsed: 00:00:29.71
SQL> ed
Wrote file afiedt.sql
1 begin
2 for r in (
3 select dt,
4 dim1,
5 dim2,
6 val,
7 sum(val) over(partition by dim1 order by dt) dim1_cumulative_sum,
8 sum(val) over(partition by dim2 order by dt) dim2_cumulative_sum,
9 sum(val) over(partition by dim1, dim2 order by dt) dim1_dim2_cumulative_sum
10 from mg_t
11 order by dt
12 )
13 loop null; end loop;
14* end;
SQL> /
Elapsed: 00:00:53.77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment