please provide me sql query for below output sum query please help me

93852217_246197733117734_2443195689677619200_n.jpg

Probably something like this:

SELECT * 
FROM (
    SELECT product_id, SUM(quantity) AS purchase
    FROM purchase 
    GROUP BY product_id
) P
JOIN (
    SELECT product_id, SUM(quantity) AS sale
    FROM sale
    GROUP BY product_id
) S ON S.product_id = P.product_id

please any one help me

commented: If you need more help, explain what's wrong with my solution. +15

Dear sir please help me, here product id 4 is not entry to sale column but i want to show purchase column result as like below picture. sir please help be as before code. thanks

22222.jpg

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.