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_totales_comex
@cuit varchar(13)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @total_impo decimal(15,2)
DECLARE @total_expo decimal(15,2)
declare @max_periodo int,@min_periodo int
set @max_periodo = (select convert(varchar(6),max(fecha_informacion),112) as fecha_informacion from fuentes_procesadas where fuente='comex_pais_rubro' and visible =1)
set @min_periodo = (select convert(varchar(6),DATEADD(month, -24, max(fecha_informacion)),112) as fecha_informacion from fuentes_procesadas where fuente='comex_pais_rubro' and visible =1)
set @total_impo = ( select sum(isnull(valor_mensual,0)) from comex_pais where cuit = @cuit and activo = 1 and tipo_operacion = 'IMPO' and pais= 'Totales' and periodo between @min_periodo and @max_periodo)
set @total_expo = ( select sum(isnull(valor_mensual,0)) from comex_pais where cuit = @cuit and activo = 1 and tipo_operacion = 'EXPO' and pais= 'Totales' and periodo between @min_periodo and @max_periodo)
select @total_impo as total_impo , @total_expo as total_expo
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.obtener_totales_comex
@cuit varchar(13)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @total_impo decimal(15,2)
DECLARE @total_expo decimal(15,2)
declare @max_periodo int,@min_periodo int
set @max_periodo = (select convert(varchar(6),max(fecha_informacion),112) as fecha_informacion from fuentes_procesadas where fuente='comex_pais_rubro' and visible =1)
set @min_periodo = (select convert(varchar(6),DATEADD(month, -24, max(fecha_informacion)),112) as fecha_informacion from fuentes_procesadas where fuente='comex_pais_rubro' and visible =1)
set @total_impo = ( select sum(isnull(valor_mensual,0)) from comex_pais where cuit = @cuit and activo = 1 and tipo_operacion = 'IMPO' and pais= 'Totales' and periodo between @min_periodo and @max_periodo)
set @total_expo = ( select sum(isnull(valor_mensual,0)) from comex_pais where cuit = @cuit and activo = 1 and tipo_operacion = 'EXPO' and pais= 'Totales' and periodo between @min_periodo and @max_periodo)
select @total_impo as total_impo , @total_expo as total_expo
END
GO
Depends On
2Used By
No items found