जैसे आप COUNT(Customer_Nbr)
. चुनते हैं पहली सबक्वेरी में, इसे दूसरी सबक्वेरी में भी चुनें:
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
और मुख्य क्वेरी में GREATEST()
. का उपयोग करें अधिकतम मान चुनने के लिए:
SELECT b.Entity_Name,
GREATEST(b.`Total Customer`, p.`Total Customer`) AS `Total Customer`
.........................