alexa
Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry

LEFT JOIN 3 tables with group by and get sum in SQL ?

LEFT JOIN 3 tables with group by and get sum in SQL ?

ou could do a double join using a temporary table :

 INSERT INTO t_final(customer_id,customer_name,order_amount) SELECT
    c.customer_id,
    c.customer_name,
    SUM(o.order_amount)
FROM      t_customer c
INNER JOIN t_order o ON c.customer_id = o.customer_id GROUP BY c.customer_id, c.customer_name;
UPDATE t_final SET pay_amount = (SELECT 
    SUM(p.pay_amount)
FROM t_payment p WHERE t_final.customer_id = p.customer_id GROUP BY t_final.customer_id LIMIT 1);
SELECT * FROM t_final;

95 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online