Aggregation Query

Analytics

Aggregation Query

Hi Guys,

 

I have been trouble writing a SQL query to roll up multiple balances based on a similar ID group and display the balance against the product with a flag of N: 

 

The desired results are below. Would anyone have a fix for this available?  As you could see the client '1' maintains all its attributes except the balance field receives the aggregation of the other records.

 

Would anyone know a query for this? 

 

Table

Table        
Client Limit  Balance  Exposure PDCT_TYPE_CTRAN_GLS_PDCT_CPDCT_XFLAGID
1   60,000,000.00                                                  -     4,000,000.00DERIVNULLDERIVN2
2                           -                              2,000,000.00                        -  FX   NULLIAY2
3                           -                              1,000,000.00                        -  IC   NULLFXY2

 

Desired Results 

 

Client Limit  Balance  Exposure PDCT_TYPE_CTRAN_GLS_PDCT_CPDCT_XFLAGID
1   60,000,000.00                            3,000,000.00   4,000,000.00DERIVNULLDERIVN200000
1 REPLY
N/A

Re: Aggregation Query

aggregation of the other records:

SUM(balance) OVER (PARTITION BY id)

product with a flag of N: add a final

QUALIFY flag = 'N'