The following MySQL query gives the output below (except the last line of output):
SELECT
`dealer_name` AS 'Dealer',
SUM(CASE WHEN `account_status` = 'WITH_CUSTOMER' THEN 1 ELSE 0 END) AS 'WITH_CUSTOMER',
SUM(CASE WHEN `account_status` = 'OUT_FOR_REPO' THEN 1 ELSE 0 END) AS 'OUT_FOR_REPO',
SUM(CASE WHEN `account_status` = 'REPOSSESSED' THEN 1 ELSE 0 END) AS 'REPOSSESSED',
SUM(CASE WHEN `account_status` IN ('WITH_CUSTOMER', 'OUT_FOR_REPO', 'REPOSSESSED') THEN 1 ELSE 0 END) AS 'Totals'
FROM tmp_table_dealer_performance
GROUP BY `dealer_name`;
Dealer WTH_CUSTOMER OUT_FOR_REPO REPOSSESSED Totals
Gas Automotive 3 0 1 4
Exclusive Automotive 3 0 0 3
Trust Auto 3 0 1 4
Any Credit Auto sales 0 1 0 1
In Power Motors 13 1 2 16
Great Deals Auto Sales 3 0 1 4
USA Auto Inc 5 0 1 6
DR Auto 2 0 1 3
Major Auto 0 0 0 0
ALL DEALERS 32 2 7 41
How can I produce the same output using the myDBR crosstab feature?