 <pre><code> SELECT ru.whs_code, ru.pdt_code, ru.case_dt_yyyymmdd, ru.fresh_frozen_status, ru.operation, ru.Qty - su.Qty AS Qty_Diff, ru.Wt - su.Wt AS Wt_Diff FROM ( SELECT whs_code, pdt_code, case_dt_yyyymmdd, fresh_frozen_status, operation, SUM(qty_cases_on_hand) AS Qty, SUM(qty_weight_on_hand) AS Wt FROM tbl_inventory_activity_rpt1 WHERE operation ='RU' GROUP BY whs_code,pdt_code,case_dt_yyyymmdd,fresh_frozen_status,operation ) ru, ( SELECT whs_code, pdt_code, case_dt_yyyymmdd, fresh_frozen_status, operation, SUM(qty_cases_on_hand) AS Qty, SUM(qty_weight_on_hand) AS Wt FROM tbl_inventory_activity_rpt1 WHERE operation ='SU' GROUP BY whs_code,pdt_code,case_dt_yyyymmdd,fresh_frozen_status,operation ) su WHERE ru.whs_code = su.whs_code AND ru.pdt_code = su.pdt_code AND ru.case_dt_yyyymmdd = su.case_dt_yyyymmdd AND ru.fresh_frozen_status = su.fresh_frozen_status AND ru.operation = su.operation; </code></pre>