WITH ClientesComEmprestimosPendentes AS (
SELECT
c.id_cliente AS id_cliente
, c.nome AS nome_cliente
, e.id_emprestimo AS id_emprestimo
, e.valor AS valor_emprestimo
, e.Status AS status_emprestimo
, s.Pontuacao AS pontuacao
FROM tabelaemprestimo AS e
LEFT JOIN tabelaclientes AS c ON e.id_cliente = c.id_cliente
LEFT JOIN tabelascorecredito AS s ON c.id_cliente = s.id_cliente
WHERE 1=1
AND (e.Status = 0 AND s.Pontuacao < 500)
)
SELECT
id_cliente
, nome_cliente
, id_emprestimo
, status_emprestimo
, pontuacao
FROM ClientesComEmprestimosPendentes
;