please provide me sql query for below output sum query please help me
nishita_1 15
Newbie Poster
Recommended Answers
Jump to PostProbably 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
All 4 Replies
pritaeas 2,194
¯\_(ツ)_/¯ Moderator Featured Poster
nishita_1 15
Newbie Poster
pritaeas
commented:
If you need more help, explain what's wrong with my solution. +15
nishita_1 15
Newbie Poster
Santanu.Das 125
Santanu Das
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.