SELECT 
    COUNT(*) as total,
    SUM(CASE WHEN is_active = true THEN 1 ELSE 0 END) as active,
    SUM(CASE WHEN is_active = false THEN 1 ELSE 0 END) as suspended,
    SUM(CASE WHEN LOWER(tier) IN ('entreprise', 'enterprise') THEN 1 ELSE 0 END) as enterprise,
    SUM(CASE WHEN LOWER(tier) = 'pro' THEN 1 ELSE 0 END) as pro,
    SUM(CASE WHEN api_key IS NULL THEN 1 ELSE 0 END) as without_api_key
FROM users;

SELECT id, email, tier, is_active, api_key IS NOT NULL as has_api_key
FROM users 
ORDER BY tier, email;
