Is there a merciful soul who can help me with complex sql queries on CakePHP 4.x?
"SELECT SUM(a.Qte_In - b.qte_delivred) AS Stock
FROM (SELECT product_id, SUM(Qte_In) AS Qte_IN FROM besdtls WHERE product_id = 1 GROUP BY product_id) As a
JOIN (SELECT product_id, SUM(Qte_Delivred) AS Qte_Delivred FROM orderdetails WHERE product_id = 1 GROUP BY product_id) As b ON b.product_id = a.product_id
WHERE a.product_id = 1";
I just need to calculate the current stock
I need to take the sum of qte_in from the besdtls table
and i have to take sum of qte_delivered from orderdetails table