Genauso wie Sie COUNT(Customer_Nbr)
auswählen in der 1. Unterabfrage auch in der 2. Unterabfrage auswählen:
SELECT Entity_Name,
COUNT(Customer_Nbr) AS `Total Customer`,
SUM(CASE WHEN Payment_Mode = 'Online Payment' THEN Amount ELSE 0 END) AS `Online Payment`,
SUM(CASE WHEN Payment_Mode = 'Cash' THEN Amount ELSE 0 END) AS `Cash Payment`,
SUM(Amount) AS `Total Payment`
FROM mq_paymentlist
GROUP BY Entity_Name
und verwenden Sie in der Hauptabfrage GREATEST()
um den maximalen Wert auszuwählen:
SELECT b.Entity_Name,
GREATEST(b.`Total Customer`, p.`Total Customer`) AS `Total Customer`
.........................