Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Accumulated or YTD Calculations

791732May 10 2011 — edited May 10 2011
Hi,

I need to calculate YTD calculation on primary key- claim_id. I have learned how I can do this but in the case I need to start cumulating from 2nd record of particular S_ID. Not sure if this is possible. I really appreciate your time.

Using 10g and 11g
CLAIM_ID	S_ID	PAID	SERVICE_DATE
123	S001	12	1-Jan-2010
124	S002	14	2-Jan-2010
125	S001	80	3-May-2010
126	S003	-86	4-Jul-2010
127	S001	54	1-Aug-2010
128	S001	45	2-Sep-2010
129	S002	87	3-Sep-2010
130	S001	89	4-Sep-2010
131	S003	55	1-Nov-2010
132	S004	56	2-Dec-2010
133	S003	52	3-Dec-2010
Desired Output:
CLAIM_ID	S_ID	YTD_PAID
123	S001	0
125	S001	12
127	S001	92
128	S001	146
130	S001	191
124	S002	0
129	S002	14
126	S003	0
131	S003	-86
133	S003	-31
132	S004	21
This post has been answered by Frank Kulash on May 10 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 7 2011
Added on May 10 2011
6 comments
360 views