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 OVER PARTITION BY condition?

RichardSquiresJul 22 2004 — edited Jul 22 2004
I have a piece of SQL similar to:

SELECT person,
amount,
type,
SUM(amount) OVER (PARTITION BY person) sum_amount_person
FROM table_a

What I would like to be able to do is use a conditional PARTITION BY clause, so rather than partition and summing for each person I would like to be able to sum for each person where type = 'ABC'

I would expect the syntax to be something like

SELECT person,
amount,
type,
SUM(amount) OVER (PARTITION BY person WHERE type = 'ABC') sum_amount_person
FROM table_a

Is this possible? Or am I missing a much simpler solution?

Richard
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 19 2004
Added on Jul 22 2004
3 comments
11,946 views