I'm looking for solution opposite this question.
I want to self-join tableA as tableB so where clause would not affect tableB result.
I want to get sum of all customers and sum of customers with cancel_date='0000-00-00'
I don't want to switch the places of the tables tableA and tableB. I do have other where
and select
statements based on tableA.
SELECT
count(tableA.client_id) as c_total,
count(tableB.client_id) as all_c_total
FROM (tableA) LEFT JOIN tableA tableB ON tableA.client_id = tableB.client_id
WHERE tableA.`cancel_date` = '0000-00-00'
GROUP BY month(tableA.purch_date)
ORDER BY month(tableA.purch_date)
The result should looks like this:
---------------------
c_total | all_c_total
---------------------
251 | 273
45 | 65
12 | 15
23 | 29