I need to remove the subquery. But I must maintain the condition. What can I do?
(SELECT * FROM customer_orders where status=3)
SELECT cus.id,cus.customer_name,cus.mobile,cus.email,
COUNT(CAST(cus_ord.customer_id AS INT)) AS Total_Order ,SUM(cus_ord.order_total_amt) AS Total_Amount
FROM customers as cus
LEFT JOIN (SELECT * FROM customer_orders where status=3) as cus_ord on CAST(cus_ord.customer_id AS INT)= CAST(cus.id AS INT)
GROUP BY CAST(cus.id AS INT)
You can move the condition in the
ONclause:Also:
is equivalent to just: