SELECT 
    US.ID, 
    US.display_name as name,
    US.user_email AS email, 
    TEL.meta_value as telefone,
    CPF.meta_value as cpf,
    COUNT(PO.ID) as total_materias
FROM psj_users US
LEFT JOIN psj_usermeta TEL ON TEL.user_id = US.ID AND TEL.meta_key = 'phone'
LEFT JOIN psj_usermeta CPF ON CPF.user_id = US.ID AND CPF.meta_key = 'cpf'
LEFT JOIN psj_posts PO ON PO.post_author = US.ID
WHERE US.user_registered > '2024-01-01'
GROUP BY 
    US.ID,
    TEL.umeta_id,
    CPF.umeta_id
HAVING COUNT(PO.ID) = 0;