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!

SUM without Group by

SeshuGiriOct 2 2007 — edited Oct 2 2007

Hi,

I have a table like this..

Type 	Amount 	ID 	Num 	ActId
Primary 256.32 	12345 	01 	7899
None	125.21 	12345 	01 	7900
None	456.87 	12345 	01 	7901

Primary 1258.45	98745 	04 	7902

Primary 468.11 	45565 	06 	7903
None	1258.45	45565 	06 	7904

None 	200.00 	85598 	09 	7905

I want to sum Amounts based on ID and Type. I DON'T want to use GROUP BY.. I want SUM (Amount) OVER (PARTITION BY ..

Result:

Type 	Amount 	ID 	Num
Primary 838.4 	12345 	01 		-- Sum of First 3 rows
Primary 1258.45	98745 	04 -- display 4th row directly becuase its primary
Primary 1726.56	45565 	06 		-- Sum of 5th and 6th rows

thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 30 2007
Added on Oct 2 2007
2 comments
2,478 views