Análise de proposta por login em determinada Matriz.
select
c.[Login],
c.Nome as NomeUsuario,
e.nome as Matriz,
count(a.Id) as QtdPropostas
from
proposta a with(nolock)
join
unidade b with(nolock) on a.UnidadeId = b.id and b.Ativo = 1
join
seguranca.usuario c with(nolock ) on a.UsuarioId = c.Id and c.Ativo = 1
join
unidade e with(nolock) on b.CorrespondenteId = e.CorrespondenteId and e.tipo = 0
join
Correspondente d with(nolock) on c.CorrespondenteId = d.Id
where
d.Id = 539
group by
c.[Login], b.Id,e.Nome,c.Nome
order by
QtdPropostas desc
No Comments