There are 3 different tables and from first table i get the "contact_id" and based on this i would like to do the SUM into the next 2 tables and then MINUS the tables as in the code bellow.
I am trying to use the result "contact_id" from the first query into the following queries
SELECT ( SELECT `id` FROM `civicrm_contact` WHERE `first_name` LIKE 'test2' ) AS contact_id =============================================================
SELECT ( SELECT SUM(`total_amount`) FROM `civicrm_contribution` WHERE `contact_id`= ) - ( SELECT SUM(`fee_amount`) FROM `civicrm_participant` WHERE `contact_id`= ) As RemainingPoints