SUM(
                    CASE 
                        WHEN `type` = 'EGAME' THEN 
                            CASE 
                                WHEN `ACTION` = '2' AND transaction_status!='cancel' THEN winloseAmount-betAmount
                                ELSE 0 
                            END
                        WHEN `type` = 'TABLE' THEN 
                            CASE 
                                WHEN `ACTION` = '2' THEN winloseAmount 
                                WHEN `ACTION` = '1' THEN -betAmount
                                WHEN `ACTION` = '2' THEN -betAmount
                                WHEN `ACTION` = '3' THEN cancel 
                                ELSE 0 
                            END 
                        ELSE 0 
                    END
                )  