cbobadillavega
9/14/2017 - 5:21 PM

Indicadores - Audit

Indicadores - Audit

select  
	Campaña = ac.name,	Fecha_Inicio = ac.start_Date, Fecha_Fin = ac.end_date, 
	Punto_Vta = b.code,
	Codigo_Preventista = u.Code, Nombre_Preventista = u.Name, 
	Series_Escaneadas = count(distinct sa.code)
from audit.audit_campaigns ac (nolock) 
inner join audit.audit_campaign_user acu (nolock) on ac.audit_campaignId = acu.audit_campaignId 
inner join audit.audits a (nolock) on ac.audit_campaignId = a.audit_campaignId and acu.userId = a.userId
inner join audit.assets sa (nolock) on sa.auditId = a.auditId
inner join dbo.so_user u (nolock) on acu.userId = u.userId and u.status = 1
inner join dbo.so_branch b (nolock) on ac.branchId = b.branchId and b.status = 1
where   cast(ac.start_Date as date) <= cast(getdate() as date)  
		and cast(ac.end_date as date) >= cast(getdate()  as date)  --auditoria vigente para la fecha en curso
group by ac.name,ac.start_Date,ac.end_date,b.code, u.code,u.Name