dbo.obtener_porcentaje_por_grupo

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

1
Name Data Type Length Description
@cuit varchar 20

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO

/*
exec obtener_porcentaje_por_grupo '27264711644'

exec obtener_porcentaje_por_grupo '20999999998'
*/


CREATE OR ALTER PROCEDURE dbo.obtener_porcentaje_por_grupo 
@cuit varchar(20)
AS
BEGIN
 SET NOCOUNT ON;
 declare @contables int,@recalculo float
 set @contables = (select count(*)  from balances_contables where cuit = @cuit and visible = 1 and datediff(YY,fecha_balance,getdate()) < 7 ) 
 if(@contables > 0)
 begin
  select judicial,cendeu,cheques,fiscal,formal,contable from score_indice_combinacion_general
  end
 else
  begin
  set @recalculo =  (select judicial+cendeu+cheques+fiscal+formal from score_indice_combinacion_general)
  (select cast((judicial/@recalculo*100) as decimal(3,1)) as judicial,
  cast((cendeu/@recalculo*100) as decimal(3,1)) as cendeu,
  cast((cheques/@recalculo*100) as decimal(3,1)) as cheques,
  cast((fiscal/@recalculo*100) as decimal(3,1)) as fiscal,
  cast((formal/@recalculo*100) as decimal(3,1)) as formal
   from score_indice_combinacion_general)
  end
END
GO

Used By

No items found