SELECT account, SUM(amount) AS subtotal ;
FROM mytable ;
GROUP BY account ;
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 = mt.account ;
INTO CURSOR crsResult
>
>How to create the formula to calculate the percentage out of the total in general format can be used all along ? from mytable.dbf
>
>account amount percentage
>
>11111 100 0.16
>11111 200 0.34
>11111 300 0.50
>---------------
>subtotal 600
>
>22222 200 0.25
>22222 200 0.25
>22222 400 0.50
>--------------
>subtotal 800
>
>
>I got the columns account , amount but need to calculate the percentage but be carefull , each time the account changes the formula of percentage should changed accordingly.
>
>Thanks in advance,
--sb--