SELECT account, ClassCode, SUM(amount) AS subtotal ; FROM mytable ; GROUP BY account, ClassCode ; INTO CURSORS crsST SELECT mt.account, mt.amount, ROUND(mt.amount/st.subtotal,2) AS percentage FROM mytable mt ; JOIN crsST st ON st.account+st.ClassCode = mt.account+mt.ClassCode ; INTO CURSOR crsResultThat is if the Account it Char type