The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

java computation issue

Question background:

One Bank Information System needs to figure out mobile average(MA)( On the chart, the mobile average is a trend line which smoothes the recurrences of the days and provides you with a quick overview of the period trend) amount of monthly loan from Loan Table defined as below,

Time

amount

…

3/14/2011

$43,334.10

…

3/15/2011

$92,304.10

...

3/16/2011

$45,983.80

...

3/17/2011

$36,973.10

...

3/18/2011

$24,987.87

...

...

...

...

It is easy for SQL to calculate monthly loan by grouping by. But I don't know how to make it out with sql as relative location and cross row computation are involved , Soppose we do it purely with java, following the codes:

....
Except pure java coding, I think this kind of data process job could also be done by sql or esProc and maybe esProc will be easier. But I don't know too much about sql, hope people viewing my thread could give some tips.