dbo.IV_clientes_

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
EXEC LN_contrapartes_queue_cliente 'todos'
exec LN_contrapartes_queue_cliente 'pendientes' , 5546348
*/

CREATE OR ALTER PROCEDURE dbo.IV_clientes_ 
AS
BEGIN
 SET NOCOUNT ON;
 select  ln_contrapartes.cliente as cliente, clientes.nombre_cliente, 
   count(*) as contrapartes 
   from LN_contrapartes 
   inner join clientes on clientes.cliente = LN_contrapartes.cliente
   inner join LN_gestiones on LN_contrapartes.contraparte = LN_gestiones.contraparte
   inner join LN_contraparte_familias on LN_contrapartes.contraparte = LN_contraparte_familias.contraparte
   inner join LN_familias on (LN_contraparte_familias.familia = LN_familias.familia
         AND LN_contrapartes.cliente = LN_familias.cliente)  
   where LN_contrapartes.activo = 1
   --and LN_contrapartes.subcontratista = 0
   and LN_contraparte_familias.activo = 1
   and LN_familias.visible = 1
   and LN_gestiones.desde <= GETDATE()
   and LN_gestiones.hasta >= GETDATE()
   and ln_gestiones.vigente = 1
   and ln_contrapartes.servicio_contratado = 10 
   --and ln_contrapartes.cliente = 2787462
   group by ln_contrapartes.cliente, clientes.nombre_cliente
end 

GO

Used By

No items found