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!

How to group records of different values

user2081225Jul 21 2010 — edited Jul 23 2010
Hi,

I have few records in table in this form:

CDE_FUND_CODE| |CDE_CLM_TYPE| |NUM_PCT| |NUM_SVC_DAYS| |
===========| |==========| |======| |==========| |
3R2A | | I | | 0.7215 | | 1 | |
3R2A | | I | | 0.2785 | | 1 | |
3R2A | | I | | 0.7215 | | 2 | |
3R2A | | I | | 0.2785 | | 2 | |
3R2A | | I | | 1.0000 | | 1 | |
3R2A | | I | | 0.2598 | | 1 | |
3R2A | | I | | 0.2401 | | 1 | |
3R2A | | I | | 0.5001 | | 1 | |

Now the notice the values of NUM_PCT
1) Sum of num_pct of first 2 records is 1.
2) Sum of num_pct of records 3rd and 4th is also 1.
3) num_pct of 5th record is 1.
4) Sum of num_pct of records 6th, 7th and 8th is 1.

So I want to write a query which gives me total 4 rows and output should look like this:-

CDE_FUND_CODE| |CDE_CLM_TYPE| |NUM_PCT| |NUM_SVC_DAYS| |
===========| |==========| |======| |==========| |
3R2A | | I | | 1.0000 | | 1 | |
3R2A | | I | | 1.0000 | | 2 | |
3R2A | | I | | 1.0000 | | 1 | |
3R2A | | I | | 1.0000 | | 1 | |

Please let me know if you have any idea about how to write query to get this output.

Thanks,
Rohit

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 20 2010
Added on Jul 21 2010
6 comments
1,329 views