Man of Honour
I have a query that outputs the following
Client, Deal Sequence, Balance
1000,1,345.56
1001,1,300.00
1001,2,300.00
1001,2,300.00
1002,1,345.00
I'd like to change the query so that the balance only appear on the first occurrence where there is more than 1 record per client
so the example above should look like this:
Client, Deal Sequence, Balance
1000,1,345.56
1001,1,300.00
1001,2,0
1001,2,0
1002,1,345.00
I'm a bit stuck on how I can achieve this tbh.
Any help would be appreciated.
Thanks
Client, Deal Sequence, Balance
1000,1,345.56
1001,1,300.00
1001,2,300.00
1001,2,300.00
1002,1,345.00
Code:
SELECT
D.CIF_NO,
D.SERIAL_NO,
(select sum(-1 * (CASE ACCOUNT_GROUP WHEN 'CALL' THEN CV_AVAIL_BAL ELSE 0 END)) from ACCOUNTS A where D.CIF_NO = A.CIF_SUB_NO ) as Balance
from
DEALS D
I'd like to change the query so that the balance only appear on the first occurrence where there is more than 1 record per client
so the example above should look like this:
Client, Deal Sequence, Balance
1000,1,345.56
1001,1,300.00
1001,2,0
1001,2,0
1002,1,345.00
I'm a bit stuck on how I can achieve this tbh.
Any help would be appreciated.
Thanks