Rolling SUM – Oracle Query


Berikut contoh rolling sum dengan query oracle :

Contoh data fisik :

BUDAT PORSI
20120401 1,50
20120402 1,50
20120403 1,50
20120404 1,50
20120405 1,50
20120406 1,50
20120407 1,00
20120408 1,00
20120409 1,00

Query :

select budat, 
sum(porsi) OVER(ORDER BY budat ROWS 
BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) "PORSI"
 from zreport_porsi_sales_region
 where budat between '20120401' and '20120431'

Hasil Query :

BUDAT PORSI
20120401 1,50
20120402 3,00
20120403 4,50
20120404 6,00
20120405 7,50
20120406 9,00
20120407 10,00
20120408 11,00
20120409 12,00

Semoga bermanfaat🙂

About blackphp

All about programming php, ajax, jquery, mysql, etc, tips n trick. Now, i'm concern in php programming with codeigniter framework n also training my design skill with photoshop or corel... wish me luck! ('o')

Posted on April 11, 2012, in Oracle and tagged , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: