I have two mysql table and I have build to select query using this two tables, both query output is a summation of quantity from inventory_transfer_details table. I need to subtract "total_to" from "total_from". please check below is mysql tables.
below is my two queries.
First query:
select sum(b.transfer_quantity) as total_to
from inventory_transfers as a
join inventory_transfer_details as b on a.id = b.inventory_transfer_id
where a.status="approved" and b.inventory_or_composite_id = '1' and a.to_warehouse_id = '2'
second query:
select sum(b.transfer_quantity) as total_from
from inventory_transfers as a
join inventory_transfer_details as b on a.id = b.inventory_transfer_id
where a.status="approved" and b.inventory_or_composite_id = '1' and a.from_warehouse_id = '2'
I need to subtract from query transfer_to to transfer_from
can you have any guide to convert this final query to laravel query?