Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with SUM( ) 1

Status
Not open for further replies.

ptheriault

IS-IT--Management
Aug 28, 2006
2,699
US
Can someone explain how this works. I am new to PL/SQL.

-SUM(C.MED_RES) AS MED_LOSS_RESERVE
 
What you have posted will not work.
Please post the entire statement and we will be glad to help you.
 
I was looking to find out the differnce between sum and -sum
SELECT TO_CHAR(C.LOSS_DATE,'YYYY') AS ACC_YEAR
,SUM(CASE WHEN C.CLAIM_TYPE <> '01' THEN C.IND_PAY+C.S_IND_REC+C.O_IND_REC ELSE 0 END) AS IND_PAID_LOSS
,-SUM(CASE WHEN C.CLAIM_TYPE <> '01' THEN C.IND_RES ELSE 0 END) AS IND_LOSS_RESERVE
,SUM(C.MED_PAY+C.S_MED_REC+C.O_MED_REC) AS MED_PAID_LOSS
,-SUM(C.MED_RES) AS MED_LOSS_RESERVE
,SUM(CASE WHEN C.CLAIM_TYPE <> '01' AND C.STATUS IN('O','RO','RS') THEN C.IND_PAY+C.S_IND_REC+C.O_IND_REC ELSE 0 END) AS IND_PAID
,SUM(C.EXP_PAY+C.S_EXP_REC+C.O_EXP_REC) AS PAID_ALAE
,SUM(CASE WHEN C.CLAIM_TYPE <> '01' AND C.STATUS IN('O','RO','RS') THEN 1 ELSE 0 END) AS OPEN_IND_COUNT
,SUM(CASE WHEN C.CLAIM_TYPE <> '01' AND C.IND_PAY-C.IND_RES+C.S_IND_REC+C.O_IND_REC <> 0 THEN 1 ELSE 0 END) AS TOTAL_IND_COUNT
FROM CUMULATIVE_CLAIM C
WHERE C.EVALUATION = TRUNC(END_DATE)
AND C.CARRIER_CODE = '50879'
AND C.POLICY_STATE = 'CA'
AND C.STATUS IN('O','RO','C','RS','RC')
GROUP BY TO_CHAR(C.LOSS_DATE,'YYYY')
 
Ah - now I see what's going on!
-sum is simply the additive inverse of sum. Another way of writing this would be 0 - sum(c.med_res).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top