USE hahn;
SELECT COUNT(*) as number_of_clients,
COUNT_IF(min_wallet_cid > 0) as number_of_clients_with_wallet
FROM
(SELECT ClientID as active_clients,
MIN(wallet_cid) as min_wallet_cid
FROM [home/direct/db/campaigns]
WHERE statusActive = 'Yes'
AND type <> 'wallet'
AND type <> 'mcb'
GROUP BY ClientID);