dbo.obtener_comex_totales_test

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 13

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO

CREATE OR ALTER PROCEDURE dbo.obtener_comex_totales_test
@cuit varchar(13)

AS
BEGIN
 
    SET NOCOUNT ON;
 DECLARE @total_impo decimal(15,2)
 DECLARE @total_expo decimal(15,2)
   declare @max_periodo date,@min_periodo date
 set @max_periodo  = (select max(fecha_informacion) as fecha_informacion from fuentes_procesadas where fuente='comex_pais_rubro' and visible =1)
 set @min_periodo  = (select DATEADD(month, -24, max(fecha_informacion)) as fecha_informacion from fuentes_procesadas where fuente='comex_pais_rubro' and visible =1)


 set @total_impo =  ( select sum(ROUND (fobusd,0)) from comex_importaciones where cuit = @cuit  and  fecha between @min_periodo and @max_periodo)
 set @total_expo =  ( select sum(ROUND (fobusd,0))  from comex_exportaciones where cuit = @cuit  and  fecha  between @min_periodo and @max_periodo)
 
 select @total_impo as total_impo , @total_expo as total_expo
END

GO

Used By

No items found